Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill380 committed Oct 3, 2016
1 parent 8e42ce8 commit 14bc620
Show file tree
Hide file tree
Showing 18 changed files with 152 additions and 203 deletions.
Expand Up @@ -964,8 +964,10 @@ public void flushSdkCache() throws Exception {
} }




//CHECKSTYLE:OFF
public CTLSchemaDto saveCTLSchemaWithAppToken(String body, String tenantId, public CTLSchemaDto saveCTLSchemaWithAppToken(String body, String tenantId,
String applicationToken) { String applicationToken) {
//CHECKSTYLE:ON
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("body", body); params.add("body", body);
if (tenantId != null) { if (tenantId != null) {
Expand All @@ -978,10 +980,12 @@ public CTLSchemaDto saveCTLSchemaWithAppToken(String body, String tenantId,
params, CTLSchemaDto.class); params, CTLSchemaDto.class);
} }


//CHECKSTYLE:OFF
public void deleteCTLSchemaByFqnVersionTenantIdAndApplicationToken(String fqn, public void deleteCTLSchemaByFqnVersionTenantIdAndApplicationToken(String fqn,
Integer version, Integer version,
String tenantId, String tenantId,
String applicationToken) { String applicationToken) {
//CHECKSTYLE:ON
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("fqn", fqn); params.add("fqn", fqn);
params.add("version", version); params.add("version", version);
Expand All @@ -994,8 +998,10 @@ public void deleteCTLSchemaByFqnVersionTenantIdAndApplicationToken(String fqn,
restTemplate.postForLocation(restTemplate.getUrl() + "CTL/deleteSchema", params); restTemplate.postForLocation(restTemplate.getUrl() + "CTL/deleteSchema", params);
} }


//CHECKSTYLE:OFF
public CTLSchemaDto getCTLSchemaByFqnVersionTenantIdAndApplicationToken( public CTLSchemaDto getCTLSchemaByFqnVersionTenantIdAndApplicationToken(
String fqn, Integer version, String tenantId, String applicationToken) { String fqn, Integer version, String tenantId, String applicationToken) {
//CHECKSTYLE:ON
if (tenantId != null && applicationToken != null) { if (tenantId != null && applicationToken != null) {
return restTemplate.getForObject( return restTemplate.getForObject(
restTemplate.getUrl() + "CTL/getSchema?fqn={fqn}&version={version}&tenantId={tenantId}" restTemplate.getUrl() + "CTL/getSchema?fqn={fqn}&version={version}&tenantId={tenantId}"
Expand All @@ -1012,7 +1018,9 @@ public CTLSchemaDto getCTLSchemaByFqnVersionTenantIdAndApplicationToken(
} }
} }


//CHECKSTYLE:OFF
public CTLSchemaDto getCTLSchemaById(String id) { public CTLSchemaDto getCTLSchemaById(String id) {
//CHECKSTYLE:ON
return restTemplate.getForObject(restTemplate.getUrl() + "CTL/getSchemaById?id={id}", return restTemplate.getForObject(restTemplate.getUrl() + "CTL/getSchemaById?id={id}",
CTLSchemaDto.class, id); CTLSchemaDto.class, id);
} }
Expand Down Expand Up @@ -1042,22 +1050,28 @@ public CTLSchemaMetaInfoDto promoteScopeToTenant(String applicationId, String fq
params, CTLSchemaMetaInfoDto.class); params, CTLSchemaMetaInfoDto.class);
} }


//CHECKSTYLE:OFF
public List<CTLSchemaMetaInfoDto> getSystemLevelCTLSchemas() { public List<CTLSchemaMetaInfoDto> getSystemLevelCTLSchemas() {
//CHECKSTYLE:ON
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange( ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(
restTemplate.getUrl() + "CTL/getSystemSchemas", restTemplate.getUrl() + "CTL/getSystemSchemas",
HttpMethod.GET, null, new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {}); HttpMethod.GET, null, new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {});
return entity.getBody(); return entity.getBody();
} }


//CHECKSTYLE:OFF
public List<CTLSchemaMetaInfoDto> getTenantLevelCTLSchemas() { public List<CTLSchemaMetaInfoDto> getTenantLevelCTLSchemas() {
//CHECKSTYLE:ON
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange( ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(
restTemplate.getUrl() + "CTL/getTenantSchemas", restTemplate.getUrl() + "CTL/getTenantSchemas",
HttpMethod.GET, null, new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {}); HttpMethod.GET, null, new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {});
return entity.getBody(); return entity.getBody();
} }


//CHECKSTYLE:OFF
public List<CTLSchemaMetaInfoDto> getApplicationLevelCTLSchemasByAppToken( public List<CTLSchemaMetaInfoDto> getApplicationLevelCTLSchemasByAppToken(
String applicationToken) { String applicationToken) {
//CHECKSTYLE:ON
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange( ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(
restTemplate.getUrl() + "CTL/getApplicationSchemas/" + applicationToken, restTemplate.getUrl() + "CTL/getApplicationSchemas/" + applicationToken,
HttpMethod.GET, null, new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {}); HttpMethod.GET, null, new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {});
Expand Down
Expand Up @@ -105,7 +105,8 @@ public void setUsername(String username) {
} }


@Override @Override
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor) protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor)
throws ResourceAccessException { throws ResourceAccessException {
int maxRetry = hosts.length; int maxRetry = hosts.length;
while (true) { while (true) {
Expand Down Expand Up @@ -136,7 +137,7 @@ protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCal
getCurHost(), getCurPort(), exception); getCurHost(), getCurPort(), exception);
continue; continue;
} }
url = updateURL(url); url = updateUrl(url);
isRequestFactorySet = true; isRequestFactorySet = true;
} }
} catch (RestClientException ex) { } catch (RestClientException ex) {
Expand All @@ -145,19 +146,21 @@ protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCal
} }
} }


private URI updateURL(URI url) { private URI updateUrl(URI url) {
String currentURI = url.toString(); String currentUri = url.toString();


int sufixPartIdx = currentURI.indexOf(restApiSuffix); int sufixPartIdx = currentUri.indexOf(restApiSuffix);


String defaultURIPartWithVariableHostPort = currentURI.substring(0, sufixPartIdx); String defaultUriPartWithVariableHostPort = currentUri.substring(0, sufixPartIdx);
String sufixPart = currentURI.substring(sufixPartIdx); String sufixPart = currentUri.substring(sufixPartIdx);


defaultURIPartWithVariableHostPort = defaultURIPartWithVariableHostPort.replaceFirst(url.getHost(), getCurHost()); defaultUriPartWithVariableHostPort = defaultUriPartWithVariableHostPort
defaultURIPartWithVariableHostPort = defaultURIPartWithVariableHostPort.replaceFirst(String.valueOf(url.getPort()), .replaceFirst(url.getHost(), getCurHost());
defaultUriPartWithVariableHostPort = defaultUriPartWithVariableHostPort
.replaceFirst(String.valueOf(url.getPort()),
String.valueOf(getCurPort())); String.valueOf(getCurPort()));


return URI.create(defaultURIPartWithVariableHostPort + sufixPart); return URI.create(defaultUriPartWithVariableHostPort + sufixPart);
} }


private int getCurPort() { private int getCurPort() {
Expand All @@ -181,7 +184,8 @@ private void setNewRequestFactory(int index) {
public void login(String username, String password) { public void login(String username, String password) {
this.username = username; this.username = username;
this.password = password; this.password = password;
HttpComponentsRequestFactoryBasicAuth requestFactory = (HttpComponentsRequestFactoryBasicAuth) getRequestFactory(); HttpComponentsRequestFactoryBasicAuth requestFactory =
(HttpComponentsRequestFactoryBasicAuth) getRequestFactory();
requestFactory.setCredentials(username, password); requestFactory.setCredentials(username, password);
} }


Expand Down
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */

package org.kaaproject.kaa.server.flume.sink.hdfs; package org.kaaproject.kaa.server.flume.sink.hdfs;


import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
Expand All @@ -22,6 +23,9 @@ public class HdfsSinkKey {
private String rootPath; private String rootPath;
private KaaSinkKey kaaSinkKey; private KaaSinkKey kaaSinkKey;


/**
* Instantiates a new HdfsSinkKey.
*/
public HdfsSinkKey(String rootPath, KaaSinkKey kaaSinkKey) { public HdfsSinkKey(String rootPath, KaaSinkKey kaaSinkKey) {
super(); super();
this.rootPath = rootPath; this.rootPath = rootPath;
Expand Down
Expand Up @@ -53,7 +53,15 @@ public GetDeltaRequest(String applicationToken, EndpointObjectHash configuration
} }




public GetDeltaRequest(String applicationToken, EndpointObjectHash configurationHash, boolean resyncOnly) { /**
* Create anew instance of GetDeltaRequest.
*
* @param applicationToken the application token
* @param configurationHash the configuration hash
* @param resyncOnly specify if it is only resync
*/
public GetDeltaRequest(String applicationToken, EndpointObjectHash configurationHash,
boolean resyncOnly) {
super(); super();
this.applicationToken = applicationToken; this.applicationToken = applicationToken;
this.configurationHash = configurationHash; this.configurationHash = configurationHash;
Expand Down Expand Up @@ -90,6 +98,8 @@ public boolean isResyncOnly() {
} }


public boolean isFirstRequest() { public boolean isFirstRequest() {
return getConfigurationHash() == null || getConfigurationHash().getData() == null || getConfigurationHash().getData().length == 0; return getConfigurationHash() == null
|| getConfigurationHash().getData() == null
|| getConfigurationHash().getData().length == 0;
} }
} }
Expand Up @@ -32,29 +32,14 @@


public class GetNotificationRequest { public class GetNotificationRequest {


/**
* The topic hash
*/
private final int topicHash; private final int topicHash;


/**
* The subscription commands.
*/
private List<SubscriptionCommand> subscriptionCommands; private List<SubscriptionCommand> subscriptionCommands;


/**
* The accepted unicast notifications.
*/
private List<String> acceptedUnicastNotifications; private List<String> acceptedUnicastNotifications;


/**
* The topic states.
*/
private List<TopicState> topicStates; private List<TopicState> topicStates;


/**
* The profile.
*/
private EndpointProfileDto profile; private EndpointProfileDto profile;


/** /**
Expand All @@ -66,8 +51,10 @@ public class GetNotificationRequest {
* @param acceptedUnicastNotifications the accepted unicast notifications * @param acceptedUnicastNotifications the accepted unicast notifications
* @param topicStates the topic states * @param topicStates the topic states
*/ */
public GetNotificationRequest(int topicHash, EndpointProfileDto profile, List<SubscriptionCommand> subscriptionCommands, public GetNotificationRequest(int topicHash, EndpointProfileDto profile,
List<String> acceptedUnicastNotifications, List<TopicState> topicStates) { List<SubscriptionCommand> subscriptionCommands,
List<String> acceptedUnicastNotifications,
List<TopicState> topicStates) {
super(); super();
this.topicHash = topicHash; this.topicHash = topicHash;
this.profile = profile; this.profile = profile;
Expand All @@ -76,47 +63,26 @@ public GetNotificationRequest(int topicHash, EndpointProfileDto profile, List<Su
this.topicStates = topicStates; this.topicStates = topicStates;
} }


/**
* Gets the topic hash
*
* @return topic hash
*/
public int getTopicHash() { public int getTopicHash() {
return topicHash; return topicHash;
} }


/**
* Gets the subscription commands.
*
* @return the subscription commands
*/
public List<SubscriptionCommand> getSubscriptionCommands() { public List<SubscriptionCommand> getSubscriptionCommands() {
return subscriptionCommands; return subscriptionCommands;
} }


/**
* Gets the accepted unicast notifications.
*
* @return the accepted unicast notifications
*/
public List<String> getAcceptedUnicastNotifications() { public List<String> getAcceptedUnicastNotifications() {
return acceptedUnicastNotifications; return acceptedUnicastNotifications;
} }


/**
* Gets the topic states.
*
* @return the topic states
*/
public List<TopicState> getTopicStates() { public List<TopicState> getTopicStates() {
return topicStates; return topicStates;
} }


/**
* Gets the profile.
*
* @return the profile
*/
public EndpointProfileDto getProfile() { public EndpointProfileDto getProfile() {
return profile; return profile;
} }
Expand Down
Expand Up @@ -34,19 +34,10 @@


public class GetNotificationResponse { public class GetNotificationResponse {


/**
* The notifications.
*/
private List<NotificationDto> notifications; private List<NotificationDto> notifications;


/**
* The topic list.
*/
private List<TopicDto> topicList; private List<TopicDto> topicList;


/**
* The subscription states.
*/
private Map<String, Integer> subscriptionStates; private Map<String, Integer> subscriptionStates;


private Set<String> subscriptionSet; private Set<String> subscriptionSet;
Expand Down Expand Up @@ -120,7 +111,8 @@ public void setSubscriptionStates(Map<String, Integer> subscriptionStates) {
* @return true, if successful * @return true, if successful
*/ */
public boolean hasDelta() { public boolean hasDelta() {
return (notifications != null && !notifications.isEmpty()) || (topicList != null && !topicList.isEmpty()); return (notifications != null && !notifications.isEmpty())
|| (topicList != null && !topicList.isEmpty());
} }


public boolean isSubscriptionListChanged() { public boolean isSubscriptionListChanged() {
Expand Down
Expand Up @@ -50,7 +50,8 @@ public class UpdateProfileRequest {
* @param profile the profile * @param profile the profile
* @param sdkToken the sdk token * @param sdkToken the sdk token
*/ */
public UpdateProfileRequest(String appToken, EndpointObjectHash endpointKeyHash, String accessToken, byte[] profile, String sdkToken) { public UpdateProfileRequest(String appToken, EndpointObjectHash endpointKeyHash,
String accessToken, byte[] profile, String sdkToken) {
super(); super();
this.appToken = appToken; this.appToken = appToken;
this.endpointKeyHash = endpointKeyHash; this.endpointKeyHash = endpointKeyHash;
Expand All @@ -59,47 +60,23 @@ public UpdateProfileRequest(String appToken, EndpointObjectHash endpointKeyHash,
this.sdkToken = sdkToken; this.sdkToken = sdkToken;
} }


/**
* Gets the endpoint key hash.
*
* @return the endpoint key hash
*/
public EndpointObjectHash getEndpointKeyHash() { public EndpointObjectHash getEndpointKeyHash() {
return endpointKeyHash; return endpointKeyHash;
} }


/**
* Gets the profile.
*
* @return the profile
*/
public byte[] getProfile() { public byte[] getProfile() {
return Arrays.copyOf(profile, profile.length); return Arrays.copyOf(profile, profile.length);
} }


/**
* Gets the application token.
*
* @return the application token
*/
public String getApplicationToken() { public String getApplicationToken() {
return appToken; return appToken;
} }


/**
* Gets the access token.
*
* @return the access token
*/
public String getAccessToken() { public String getAccessToken() {
return accessToken; return accessToken;
} }


/**
* Gets the sdk token.
*
* @return the sdk token
*/
public String getSdkToken() { public String getSdkToken() {
return sdkToken; return sdkToken;
} }
Expand Down
Expand Up @@ -23,9 +23,7 @@
import org.kaaproject.kaa.server.operations.service.akka.messages.core.user.UserConfigurationUpdate; import org.kaaproject.kaa.server.operations.service.akka.messages.core.user.UserConfigurationUpdate;
import org.kaaproject.kaa.server.transport.message.MessageHandler; import org.kaaproject.kaa.server.transport.message.MessageHandler;


/**
* The Interface AkkaService.
*/
public interface AkkaService extends MessageHandler { public interface AkkaService extends MessageHandler {


/** /**
Expand All @@ -36,7 +34,7 @@ public interface AkkaService extends MessageHandler {
ActorSystem getActorSystem(); ActorSystem getActorSystem();


/** /**
* On redirection rule set * On redirection rule set.
* *
* @param redirectionRule the redirection rule * @param redirectionRule the redirection rule
*/ */
Expand All @@ -50,13 +48,14 @@ public interface AkkaService extends MessageHandler {
void onNotification(Notification notification); void onNotification(Notification notification);


/** /**
* Reports update of user configuration to the global user actor * Reports update of user configuration to the global user actor.
* *
* @param update - user configuration update * @param update - user configuration update
*/ */
void onUserConfigurationUpdate(UserConfigurationUpdate update); void onUserConfigurationUpdate(UserConfigurationUpdate update);


void setStatusListener(AkkaStatusListener defaultLoadBalancingService, long loadStatsUpdateFrequency); void setStatusListener(AkkaStatusListener defaultLoadBalancingService,
long loadStatsUpdateFrequency);


void removeStatusListener(); void removeStatusListener();
} }

0 comments on commit 14bc620

Please sign in to comment.