Skip to content

Commit

Permalink
ATLAS-4960: checkstyle compliance updates - atlas-intg module (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
mneethiraj authored Jan 24, 2025
1 parent 155c854 commit 6ff6b62
Show file tree
Hide file tree
Showing 175 changed files with 8,657 additions and 8,576 deletions.
1 change: 1 addition & 0 deletions dev-support/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
<suppress files="[\\/]target[\\/]" checks="[a-zA-Z0-9]*"/>
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
<suppress files="[\\/]surefire-reports[\\/]" checks="[a-zA-Z0-9]*"/>
<suppress files="Id.java" checks="MethodName"/>
</suppressions>
5 changes: 5 additions & 0 deletions intg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<name>Apache Atlas Integration</name>
<description>Apache Atlas Integration</description>

<properties>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
<checkstyle.skip>false</checkstyle.skip>
</properties>

<dependencies>

<dependency>
Expand Down
200 changes: 111 additions & 89 deletions intg/src/main/java/org/apache/atlas/ApplicationProperties.java

Large diffs are not rendered by default.

43 changes: 22 additions & 21 deletions intg/src/main/java/org/apache/atlas/AtlasConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -32,7 +32,7 @@ public enum AtlasConfiguration {
WEBSERVER_QUEUE_SIZE("atlas.webserver.queuesize", 100),
WEBSERVER_REQUEST_BUFFER_SIZE("atlas.jetty.request.buffer.size", 16192),

QUERY_PARAM_MAX_LENGTH("atlas.query.param.max.length", 4*1024),
QUERY_PARAM_MAX_LENGTH("atlas.query.param.max.length", 4 * 1024),

REST_API_ENABLE_DELETE_TYPE_OVERRIDE("atlas.rest.enable.delete.type.override", false),
NOTIFICATION_RELATIONSHIPS_ENABLED("atlas.notification.relationships.enabled", false),
Expand All @@ -47,7 +47,7 @@ public enum AtlasConfiguration {
NOTIFICATION_HOOK_CONSUMER_TOPIC_NAMES("atlas.notification.hook.consumer.topic.names", "ATLAS_HOOK"), // a comma separated list of topic names
NOTIFICATION_ENTITIES_CONSUMER_TOPIC_NAMES("atlas.notification.entities.consumer.topic.names", "ATLAS_ENTITIES"), // a comma separated list of topic names

NOTIFICATION_REST_BODY_MAX_LENGTH_BYTES("atlas.notification.rest.body.max.length.bytes", (1 * 1024 * 1024)),
NOTIFICATION_REST_BODY_MAX_LENGTH_BYTES("atlas.notification.rest.body.max.length.bytes", (1024 * 1024)),
NOTIFICATION_MESSAGE_MAX_LENGTH_BYTES("atlas.notification.message.max.length.bytes", (1000 * 1000)),
NOTIFICATION_MESSAGE_COMPRESSION_ENABLED("atlas.notification.message.compression.enabled", true),
NOTIFICATION_SPLIT_MESSAGE_SEGMENTS_WAIT_TIME_SECONDS("atlas.notification.split.message.segments.wait.time.seconds", 15 * 60),
Expand Down Expand Up @@ -80,7 +80,7 @@ public enum AtlasConfiguration {
LINEAGE_ON_DEMAND_DEFAULT_NODE_COUNT("atlas.lineage.on.demand.default.node.count", 3),
LINEAGE_MAX_NODE_COUNT("atlas.lineage.max.node.count", 9000),

HTTP_HEADER_SERVER_VALUE("atlas.http.header.server.value","Apache Atlas"),
HTTP_HEADER_SERVER_VALUE("atlas.http.header.server.value", "Apache Atlas"),
STORAGE_CONSISTENCY_LOCK_ENABLED("atlas.graph.storage.consistency-lock.enabled", true),
REBUILD_INDEX("atlas.rebuild.index", false),
PROCESS_NAME_UPDATE_PATCH("atlas.process.name.update.patch", false),
Expand All @@ -92,8 +92,8 @@ public enum AtlasConfiguration {
TASKS_USE_ENABLED("atlas.tasks.enabled", true),
SESSION_TIMEOUT_SECS("atlas.session.timeout.secs", -1),
UPDATE_COMPOSITE_INDEX_STATUS("atlas.update.composite.index.status", true),
METRICS_TIME_TO_LIVE_HOURS( "atlas.metrics.ttl.hours", 336), // 14 days default
SOLR_INDEX_TX_LOG_TTL_CONF("write.ahead.log.ttl.in.hours", 240), //10 days default
METRICS_TIME_TO_LIVE_HOURS("atlas.metrics.ttl.hours", 336), // 14 days default
SOLR_INDEX_TX_LOG_TTL_CONF("write.ahead.log.ttl.in.hours", 240), //10 days default

ATLAS_AUDIT_AGING_ENABLED("atlas.audit.aging.enabled", false),
ATLAS_AUDIT_DEFAULT_AGEOUT_ENABLED("atlas.audit.default.ageout.enabled", true),
Expand All @@ -109,20 +109,12 @@ public enum AtlasConfiguration {
MIN_AUDIT_COUNT_TO_MAINTAIN("atlas.audit.min.count.to.maintain", 50),
ATLAS_AUDIT_AGING_SEARCH_MAX_LIMIT("atlas.audit.aging.search.maxlimit", 10000),
ATLAS_AUDIT_DEFAULT_AGEOUT_IGNORE_TTL("atlas.audit.default.ageout.ignore.ttl", false),
ATLAS_AUDIT_AGING_TTL_TEST_AUTOMATION("atlas.audit.aging.ttl.test.automation", false),//Only for test automation
RELATIONSHIP_SEARCH_ENABLED("atlas.relationship.search.enabled" ,false),
ATLAS_AUDIT_AGING_TTL_TEST_AUTOMATION("atlas.audit.aging.ttl.test.automation", false), //Only for test automation
RELATIONSHIP_SEARCH_ENABLED("atlas.relationship.search.enabled", false),
UI_TASKS_TAB_USE_ENABLED("atlas.tasks.ui.tab.enabled", false);

private static final Configuration APPLICATION_PROPERTIES;

static {
try {
APPLICATION_PROPERTIES = ApplicationProperties.get();
} catch (AtlasException e) {
throw new RuntimeException(e);
}
}

private final String propertyName;
private final Object defaultValue;

Expand All @@ -136,7 +128,7 @@ public String getPropertyName() {
}

public int getInt() {
return APPLICATION_PROPERTIES.getInt(propertyName, Integer.valueOf(defaultValue.toString()).intValue());
return APPLICATION_PROPERTIES.getInt(propertyName, Integer.parseInt(defaultValue.toString()));
}

public long getLong() {
Expand All @@ -154,7 +146,7 @@ public String getString() {
public String[] getStringArray() {
String[] ret = APPLICATION_PROPERTIES.getStringArray(propertyName);

if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
if (defaultValue != null) {
ret = StringUtils.split(defaultValue.toString(), ',');
}
Expand All @@ -166,7 +158,7 @@ public String[] getStringArray() {
public String[] getStringArray(String... defaultValue) {
String[] ret = APPLICATION_PROPERTIES.getStringArray(propertyName);

if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
if (ret == null || ret.length == 0 || (ret.length == 1 && StringUtils.isEmpty(ret[0]))) {
ret = defaultValue;
}

Expand All @@ -175,6 +167,15 @@ public String[] getStringArray(String... defaultValue) {

public Object get() {
Object value = APPLICATION_PROPERTIES.getProperty(propertyName);

return value == null ? defaultValue : value;
}

static {
try {
APPLICATION_PROPERTIES = ApplicationProperties.get();
} catch (AtlasException e) {
throw new RuntimeException(e);
}
}
}
54 changes: 27 additions & 27 deletions intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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.
Expand All @@ -21,6 +21,7 @@
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;

import java.text.MessageFormat;
import java.util.Arrays;

Expand Down Expand Up @@ -72,15 +73,15 @@ public enum AtlasErrorCode {
BAD_REQUEST(400, "ATLAS-400-00-029", "{0}"),
PARAMETER_PARSING_FAILED(400, "ATLAS-400-00-02A", "Parameter parsing failed at: {0}"),
MISSING_MANDATORY_ATTRIBUTE(400, "ATLAS-400-00-02B", "Mandatory field {0}.{1} has empty/null value"),
RELATIONSHIPDEF_INSUFFICIENT_ENDS(400, "ATLAS-400-00-02C", "relationshipDef {0} creation attempted without 2 ends"),
RELATIONSHIPDEF_DOUBLE_CONTAINERS(400, "ATLAS-400-00-02D", "relationshipDef {0} creation attempted with both ends as containers"),
RELATIONSHIPDEF_UNSUPPORTED_ATTRIBUTE_TYPE(400, "ATLAS-400-00-02F", "Cannot set an Attribute with type {0} on relationship def {1}, as it is not a primitive type "),
RELATIONSHIPDEF_ASSOCIATION_AND_CONTAINER(400, "ATLAS-400-00-030", "ASSOCIATION relationshipDef {0} creation attempted with an end specifying isContainer"),
RELATIONSHIPDEF_COMPOSITION_NO_CONTAINER(400, "ATLAS-400-00-031", "COMPOSITION relationshipDef {0} creation attempted without an end specifying isContainer"),
RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER(400, "ATLAS-400-00-032", "AGGREGATION relationshipDef {0} creation attempted without an end specifying isContainer"),
RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS(400, "ATLAS-400-00-033", "COMPOSITION relationshipDef {0} can only have one parent; so cannot have SET cardinality on children"),
RELATIONSHIPDEF_LIST_ON_END(400, "ATLAS-400-00-034", "relationshipDef {0} cannot have a LIST cardinality on an end"),
RELATIONSHIPDEF_INVALID_END_TYPE(400, "ATLAS-400-00-035", "relationshipDef {0} has invalid end type {1}"),
RELATIONSHIPDEF_INSUFFICIENT_ENDS(400, "ATLAS-400-00-02C", "relationshipDef {0} creation attempted without 2 ends"),
RELATIONSHIPDEF_DOUBLE_CONTAINERS(400, "ATLAS-400-00-02D", "relationshipDef {0} creation attempted with both ends as containers"),
RELATIONSHIPDEF_UNSUPPORTED_ATTRIBUTE_TYPE(400, "ATLAS-400-00-02F", "Cannot set an Attribute with type {0} on relationship def {1}, as it is not a primitive type "),
RELATIONSHIPDEF_ASSOCIATION_AND_CONTAINER(400, "ATLAS-400-00-030", "ASSOCIATION relationshipDef {0} creation attempted with an end specifying isContainer"),
RELATIONSHIPDEF_COMPOSITION_NO_CONTAINER(400, "ATLAS-400-00-031", "COMPOSITION relationshipDef {0} creation attempted without an end specifying isContainer"),
RELATIONSHIPDEF_AGGREGATION_NO_CONTAINER(400, "ATLAS-400-00-032", "AGGREGATION relationshipDef {0} creation attempted without an end specifying isContainer"),
RELATIONSHIPDEF_COMPOSITION_MULTIPLE_PARENTS(400, "ATLAS-400-00-033", "COMPOSITION relationshipDef {0} can only have one parent; so cannot have SET cardinality on children"),
RELATIONSHIPDEF_LIST_ON_END(400, "ATLAS-400-00-034", "relationshipDef {0} cannot have a LIST cardinality on an end"),
RELATIONSHIPDEF_INVALID_END_TYPE(400, "ATLAS-400-00-035", "relationshipDef {0} has invalid end type {1}"),
INVALID_RELATIONSHIP_END_TYPE(400, "ATLAS-400-00-036", "invalid relationshipDef: {0}: end type 1: {1}, end type 2: {2}"),
RELATIONSHIPDEF_INVALID_END1_UPDATE(400, "ATLAS-400-00-037", "invalid update for relationshipDef {0}: new end1 {1}, existing end1 {2}"),
RELATIONSHIPDEF_INVALID_END2_UPDATE(400, "ATLAS-400-00-038", "invalid update for relationshipDef {0}: new end2 {1}, existing end2 {2}"),
Expand All @@ -100,12 +101,12 @@ public enum AtlasErrorCode {
CLASSIFICATIONDEF_INVALID_ENTITYTYPES(400, "ATLAS-400-00-052", "ClassificationDef ‘{0}‘ has invalid ‘{1}‘ in entityTypes"),
CLASSIFICATIONDEF_PARENTS_ENTITYTYPES_DISJOINT(400, "ATLAS-400-00-053", "ClassificationDef ‘{0}‘ has supertypes whose entityTypes are disjoint; e.g. 2 supertypes that are not related by inheritance specify different non empty entityType lists. This means the child cannot honour the restrictions specified in both parents."),
CLASSIFICATIONDEF_ENTITYTYPES_NOT_PARENTS_SUBSET(400, "ATLAS-400-00-054", "ClassificationDef ‘{0}‘ has entityTypes ‘{1}‘ which are not subsets of it's supertypes entityTypes"),
INVALID_ENTITY_FOR_CLASSIFICATION (400, "ATLAS-400-00-055", "Entity (guid=‘{0}‘,typename=‘{1}‘) cannot be classified by Classification ‘{2}‘, because ‘{1}‘ is not in the ClassificationDef's restrictions."),
INVALID_ENTITY_FOR_CLASSIFICATION(400, "ATLAS-400-00-055", "Entity (guid=‘{0}‘,typename=‘{1}‘) cannot be classified by Classification ‘{2}‘, because ‘{1}‘ is not in the ClassificationDef's restrictions."),
SAVED_SEARCH_CHANGE_USER(400, "ATLAS-400-00-056", "saved-search {0} can not be moved from user {1} to {2}"),
INVALID_QUERY_PARAM_LENGTH(400, "ATLAS-400-00-057" , "Length of query param {0} exceeds the limit"),
INVALID_QUERY_LENGTH(400, "ATLAS-400-00-058" , "Invalid query length, update {0} to change the limit" ),
INVALID_QUERY_PARAM_LENGTH(400, "ATLAS-400-00-057", "Length of query param {0} exceeds the limit"),
INVALID_QUERY_LENGTH(400, "ATLAS-400-00-058", "Invalid query length, update {0} to change the limit"),
// DSL related error codes
INVALID_DSL_QUERY(400, "ATLAS-400-00-059" , "Invalid DSL query: {0} | Reason: {1}. Please refer to Atlas DSL grammar for more information" ),
INVALID_DSL_QUERY(400, "ATLAS-400-00-059", "Invalid DSL query: {0} | Reason: {1}. Please refer to Atlas DSL grammar for more information"),
INVALID_DSL_GROUPBY(400, "ATLAS-400-00-05A", "DSL Semantic Error - GroupBy attribute {0} is non-primitive"),
INVALID_DSL_UNKNOWN_TYPE(400, "ATLAS-400-00-05B", "DSL Semantic Error - {0} type not found"),
INVALID_DSL_UNKNOWN_CLASSIFICATION(400, "ATLAS-400-00-05C", "DSL Semantic Error - {0} classification not found"),
Expand Down Expand Up @@ -168,7 +169,7 @@ public enum AtlasErrorCode {
BUSINESS_METADATA_ATTRIBUTE_DOES_NOT_EXIST(400, "ATLAS-400-00-096", "Business-metadata attribute does not exist in entity: {0}"),
BUSINESS_METADATA_ATTRIBUTE_ALREADY_EXISTS(400, "ATLAS-400-00-097", "Business-metadata attribute already exists in entity: {0}"),
INVALID_FILE_TYPE(400, "ATLAS-400-00-098", "The provided file type: {0} is not supported. Expected file formats are .csv and .xls."),
INVALID_BUSINESS_ATTRIBUTES_IMPORT_DATA(400, "ATLAS-400-00-099","The uploaded file was not processed due to following errors : {0}"),
INVALID_BUSINESS_ATTRIBUTES_IMPORT_DATA(400, "ATLAS-400-00-099", "The uploaded file was not processed due to following errors : {0}"),
ATTRIBUTE_NAME_INVALID_CHARS(400, "ATLAS-400-00-09A", "{0}: invalid name. Attribute names must begin with a letter followed by a sequence of letters, numbers, or '_' characters"),
NO_DATA_FOUND(400, "ATLAS-400-00-09B", "No data found in the uploaded file"),
NOT_VALID_FILE(400, "ATLAS-400-00-09C", "Invalid {0} file"),
Expand Down Expand Up @@ -247,30 +248,29 @@ public enum AtlasErrorCode {
FAILED_TO_UPDATE_GLOSSARY_TERM(500, "ATLAS-500-00-017", "Error occurred while updating glossary term: {0}"),
NOTIFICATION_EXCEPTION(500, "ATLAS-500-00-018", "{0}");

private String errorCode;
private String errorMessage;
private Response.Status httpCode;

private static final Logger LOG = LoggerFactory.getLogger(AtlasErrorCode.class);
private final String errorCode;
private final String errorMessage;
private final Response.Status httpCode;

AtlasErrorCode(int httpCode, String errorCode, String errorMessage) {
this.httpCode = Response.Status.fromStatusCode(httpCode);
this.errorCode = errorCode;
this.httpCode = Response.Status.fromStatusCode(httpCode);
this.errorCode = errorCode;
this.errorMessage = errorMessage;

}

public String getFormattedErrorMessage(String... params) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("<== AtlasErrorCode.getMessage(%s)", Arrays.toString(params)));
LOG.debug("<== AtlasErrorCode.getMessage({})", Arrays.toString(params));
}

MessageFormat mf = new MessageFormat(errorMessage);
String result = mf.format(params);
MessageFormat mf = new MessageFormat(errorMessage);
String result = mf.format(params);

if (LOG.isDebugEnabled()) {
LOG.debug(String.format("==> AtlasErrorCode.getMessage(%s): %s", Arrays.toString(params), result));
LOG.debug("==> AtlasErrorCode.getMessage({}): {}", Arrays.toString(params), result);
}

return result;
}

Expand Down
7 changes: 3 additions & 4 deletions intg/src/main/java/org/apache/atlas/AtlasException.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -21,7 +21,6 @@
* Base Exception class for Atlas API.
*/
public class AtlasException extends Exception {

public AtlasException() {
}

Expand Down
8 changes: 4 additions & 4 deletions intg/src/main/java/org/apache/atlas/DeleteType.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -26,7 +26,7 @@ public enum DeleteType {
HARD;

public static DeleteType from(String s) {
if(StringUtils.isEmpty(s)) {
if (StringUtils.isEmpty(s)) {
return DEFAULT;
}

Expand Down
6 changes: 3 additions & 3 deletions intg/src/main/java/org/apache/atlas/SortOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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.
Expand All @@ -19,4 +19,4 @@

public enum SortOrder {
ASCENDING, DESCENDING
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@AtlasJSON
public class BulkImportResponse implements Serializable {
private List<ImportInfo> failedImportInfoList = new ArrayList<>();
private List<ImportInfo> failedImportInfoList = new ArrayList<>();
private List<ImportInfo> successImportInfoList = new ArrayList<>();

public BulkImportResponse() {}
Expand Down Expand Up @@ -64,10 +64,6 @@ public void addToSuccessImportInfoList(ImportInfo importInfo) {
successImportInfoList.add(importInfo);
}

public enum ImportStatus {
SUCCESS, FAILED
}

@Override
public String toString() {
return "BulkImportResponse{" +
Expand All @@ -76,22 +72,25 @@ public String toString() {
'}';
}

public enum ImportStatus {
SUCCESS, FAILED
}

public static class ImportInfo {
private String parentObjectName;
private String childObjectName;
private String parentObjectName;
private String childObjectName;
private ImportStatus importStatus;
private String remarks;
private Integer rowNumber;
private String remarks;
private Integer rowNumber;

public ImportInfo(){ }
public ImportInfo() {}

public ImportInfo(String parentObjectName, String childObjectName, ImportStatus importStatus, String remarks, Integer rowNumber) {
this.parentObjectName = parentObjectName;
this.childObjectName = childObjectName;
this.importStatus = importStatus;
this.remarks = remarks;
this.rowNumber = rowNumber;
this.childObjectName = childObjectName;
this.importStatus = importStatus;
this.remarks = remarks;
this.rowNumber = rowNumber;
}

public ImportInfo(String parentObjectName, String childObjectName, ImportStatus importStatus) {
Expand Down Expand Up @@ -157,4 +156,4 @@ public String toString() {
'}';
}
}
}
}
Loading

0 comments on commit 6ff6b62

Please sign in to comment.