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

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

//CHECKSTYLE:OFF
public CTLSchemaDto getCTLSchemaByFqnVersionTenantIdAndApplicationToken(
String fqn, Integer version, String tenantId, String applicationToken) {
//CHECKSTYLE:ON
if (tenantId != null && applicationToken != null) {
return restTemplate.getForObject(
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) {
//CHECKSTYLE:ON
return restTemplate.getForObject(restTemplate.getUrl() + "CTL/getSchemaById?id={id}",
CTLSchemaDto.class, id);
}
Expand Down Expand Up @@ -1042,22 +1050,28 @@ public CTLSchemaMetaInfoDto promoteScopeToTenant(String applicationId, String fq
params, CTLSchemaMetaInfoDto.class);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
* Instantiates a new HdfsSinkKey.
*/
public HdfsSinkKey(String rootPath, KaaSinkKey kaaSinkKey) {
super();
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();
this.applicationToken = applicationToken;
this.configurationHash = configurationHash;
Expand Down Expand Up @@ -90,6 +98,8 @@ public boolean isResyncOnly() {
}

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 {

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

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

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

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

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

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

/**
* Gets the topic hash
*
* @return topic hash
*/

public int getTopicHash() {
return topicHash;
}

/**
* Gets the subscription commands.
*
* @return the subscription commands
*/

public List<SubscriptionCommand> getSubscriptionCommands() {
return subscriptionCommands;
}

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

/**
* Gets the topic states.
*
* @return the topic states
*/

public List<TopicState> getTopicStates() {
return topicStates;
}

/**
* Gets the profile.
*
* @return the profile
*/

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

public class GetNotificationResponse {

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

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

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

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

public boolean isSubscriptionListChanged() {
Expand Down
Expand Up @@ -50,7 +50,8 @@ public class UpdateProfileRequest {
* @param profile the profile
* @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();
this.appToken = appToken;
this.endpointKeyHash = endpointKeyHash;
Expand All @@ -59,47 +60,23 @@ public UpdateProfileRequest(String appToken, EndpointObjectHash endpointKeyHash,
this.sdkToken = sdkToken;
}

/**
* Gets the endpoint key hash.
*
* @return the endpoint key hash
*/

public EndpointObjectHash getEndpointKeyHash() {
return endpointKeyHash;
}

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

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

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

/**
* Gets the sdk token.
*
* @return the sdk token
*/
public String getSdkToken() {
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.transport.message.MessageHandler;

/**
* The Interface AkkaService.
*/

public interface AkkaService extends MessageHandler {

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

/**
* On redirection rule set
* On redirection rule set.
*
* @param redirectionRule the redirection rule
*/
Expand All @@ -50,13 +48,14 @@ public interface AkkaService extends MessageHandler {
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
*/
void onUserConfigurationUpdate(UserConfigurationUpdate update);

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

void removeStatusListener();
}

0 comments on commit 14bc620

Please sign in to comment.