Skip to content

Commit

Permalink
Revert "fix: validate entity type for an urn (#1958)" (#1959)
Browse files Browse the repository at this point in the history
This change should've been made in datahub-gma instead.

This reverts commit 127d84e.
  • Loading branch information
John Plaisted authored Oct 23, 2020
1 parent 127d84e commit 230ecce
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public String getFlowIdEntity() {
}

public static AzkabanFlowUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new AzkabanFlowUrn(parts[0], parts[1], parts[2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public String getJobIdEntity() {
}

public static AzkabanJobUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String content = new Urn(rawUrn).getContent();
String flowParts = content.substring(1, content.lastIndexOf(",") + 1);
String[] parts = content.substring(1, content.length() - 1).split(",");
Expand Down
5 changes: 3 additions & 2 deletions li-utils/src/main/java/com/linkedin/common/urn/ChartUrn.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public String getChartIdEntity() {
}

public static ChartUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String[] urnParts = new Urn(rawUrn).getContent().split(",");
Urn urn = new Urn(rawUrn);
validateUrn(urn, ENTITY_TYPE);
String[] urnParts = urn.getContent().split(",");
return new ChartUrn(urnParts[0], urnParts[1]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ public String getGroupNameEntity() {
}

public static CorpGroupUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String groupName = new Urn(rawUrn).getContent();
return new CorpGroupUrn(groupName);
}

public static CorpGroupUrn createFromUrn(Urn urn) throws URISyntaxException {
validateUrn(urn, ENTITY_TYPE);
if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Can't cast URN to CorpGroupUrn, not same ENTITY");
}

Matcher matcher = URN_PATTERN.matcher(urn.toString());
if (matcher.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ public String getUsernameEntity() {
}

public static CorpuserUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String username = new Urn(rawUrn).getContent();
return new CorpuserUrn(username);
}

public static CorpuserUrn createFromUrn(Urn urn) throws URISyntaxException {
validateUrn(urn, ENTITY_TYPE);
if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Can't cast URN to CorpuserUrn, not same ENTITY");
}

Matcher matcher = URN_PATTERN.matcher(urn.toString());
if (matcher.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public String getDashboardIdEntity() {
}

public static DashboardUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String[] urnParts = new Urn(rawUrn).getContent().split(",");
Urn urn = new Urn(rawUrn);
validateUrn(urn, ENTITY_TYPE);
String[] urnParts = urn.getContent().split(",");
return new DashboardUrn(urnParts[0], urnParts[1]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public String getPlatformNameEntity() {
}

public static DataPlatformUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String platformName = new Urn(rawUrn).getContent();
return new DataPlatformUrn(platformName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public FabricType getOriginEntity() {
}

public static DataProcessUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new DataProcessUrn(parts[0], parts[1], toFabricType(parts[2]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public FabricType getOriginEntity() {
}

public static DatasetUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new DatasetUrn(DataPlatformUrn.createFromString(parts[0]), parts[1], toFabricType(parts[2]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public FabricType getOriginEntity() {
}

public static MLModelUrn createFromString(String rawUrn) throws URISyntaxException {
validateUrn(rawUrn, ENTITY_TYPE);
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new MLModelUrn(DataPlatformUrn.createFromString(parts[0]), parts[1], toFabricType(parts[2]));
Expand Down
6 changes: 0 additions & 6 deletions li-utils/src/main/java/com/linkedin/common/urn/Urn.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ public static Urn deserialize(String rawUrn) throws URISyntaxException {
return createFromString(rawUrn);
}

public static void validateUrn(@Nonnull String rawUrn, @Nonnull String entityType)
throws URISyntaxException {
final Urn urn = new Urn(rawUrn);
validateUrn(urn, entityType);
}

public static void validateUrn(@Nonnull Urn urn, @Nonnull String entityType)
throws URISyntaxException {
if (!entityType.equals(urn.getEntityType())) {
Expand Down

0 comments on commit 230ecce

Please sign in to comment.