Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(uri): marks uri field as deprecated, removes problem code, and adds coercer for usages of URI typeref #7093

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ private void mapDatasetProperties(@Nonnull Dataset dataset, @Nonnull DataMap dat
properties.setQualifiedName(gmsProperties.getQualifiedName());
dataset.setProperties(properties);
dataset.setDescription(properties.getDescription());
if (gmsProperties.getUri() != null) {
dataset.setUri(gmsProperties.getUri().toString());
}
}

private void mapEditableDatasetProperties(@Nonnull Dataset dataset, @Nonnull DataMap dataMap) {
Expand Down
38 changes: 38 additions & 0 deletions li-utils/src/main/javaPegasus/com/linkedin/common/uri/Uri.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.linkedin.common.uri;

import java.net.URI;
import java.net.URISyntaxException;

public class Uri {
private final String _uri;

public Uri(String url) {
if (url == null) {
throw new NullPointerException("URL must be non-null");
}
_uri = url;
}

@Override
public String toString() {
return _uri;
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Uri)) {
return false;
} else {
return _uri.equals(((Uri) obj)._uri);
}
}

@Override
public int hashCode() {
return _uri.hashCode();
}

public URI toURI() throws URISyntaxException {
return new URI(_uri);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.linkedin.common.uri;

import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;

public class UriCoercer implements DirectCoercer<Uri> {
private static final boolean REGISTER_COERCER = Custom.registerCoercer(new UriCoercer(), Uri.class);

@Override
public Object coerceInput(Uri object) throws ClassCastException {
return object.toString();
}

@Override
public Uri coerceOutput(Object object) throws TemplateOutputCastException {
return new Uri((String) object);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ record DatasetProperties includes CustomProperties, ExternalReference {
/**
* The abstracted URI such as hdfs:///data/tracking/PageViewEvent, file:///dir/file_name. Uri should not include any environment specific properties. Some datasets might not have a standardized uri, which makes this field optional (i.e. kafka topic).
*/
@deprecated = "Use ExternalReference.externalUrl field instead."
uri: optional Uri

/**
Expand Down