Skip to content

Commit

Permalink
switch to new data endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
olinux committed Mar 7, 2022
1 parent a6ab41b commit 0a2e0c9
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

**/*.iml
node_modules
.tmp
.DS_Store
Expand All @@ -9,4 +10,4 @@ node_modules
build/
.history/
.metals
/service/.bsp
/service/.bsp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static String createEmbargoMessage(String type, FileRepository fileReposi
return String.format("%s <br/><br/>If you are an authenticated user, <a href=\"%s\" target=\"_blank\"> you should be able to access the data here</a>", message, url);
}
}
return String.format("This dataset is temporarily under embargo. The data will become available for download after the embargo period.<br/><br/>If you are an authenticated user, <a href=\"https://kg.ebrains.eu/files/cscs/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", fileRepository.getIri());
return String.format("This dataset is temporarily under embargo. The data will become available for download after the embargo period.<br/><br/>If you are an authenticated user, <a href=\"https://data.kg.ebrains.eu/files/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", fileRepository.getIri());
}
return null;
}
Expand Down Expand Up @@ -83,7 +83,7 @@ public static String translateInternalFileRepoToUrl(FileRepository repository){
return String.format("https://data-proxy.ebrains.eu/%s", id);
}
else if(isCscsContainer(repository)){
return String.format("https://kg.ebrains.eu/files/cscs/list?url=%s", repository.getIri());
return String.format("https://data.kg.ebrains.eu/files/list?url=%s", repository.getIri());
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
import java.util.stream.Stream;

public abstract class Translator<Source, Target, ListResult extends ResultsOfKG<Source>> {
public static final String fileProxy = ""; //TODO: Should that be changed ?
// public static final String fileProxy = "https://kg.ebrains.eu";
public static final String fileProxy = "https://data.kg.ebrains.eu/files";

public abstract Target translate(Source source, DataStage dataStage, boolean liveMode, DOICitationFormatter doiCitationFormatter) throws TranslationException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public DatasetVersion translate(DatasetV1 datasetV1, DataStage dataStage, boolea
List<DatasetV1.SourceFile> files = datasetV1.getFiles();
if (!datasetV1.isUseHDG() && !hasEmbargoStatus(datasetV1, EMBARGOED, UNDER_REVIEW) && StringUtils.isNotBlank(containerUrl) && CollectionUtils.isEmpty(datasetV1.getExternalDatalink()) && CollectionUtils.isEmpty(files)) {
d.setDownloadAsZip(new TargetExternalReference(
String.format("https://kg.ebrains.eu/proxy/export?container=%s", containerUrl), // TODO: Get rid of empty and containerUrlAsZip condition
String.format("https://data.kg.ebrains.eu/zip?container=%s", containerUrl), // TODO: Get rid of empty and containerUrlAsZip condition
"Download all related data as ZIP"
));
}
Expand Down Expand Up @@ -134,7 +134,7 @@ public DatasetVersion translate(DatasetV1 datasetV1, DataStage dataStage, boolea
.filter(v -> v.getAbsolutePath() != null && v.getName() != null)
.map(f ->
new TargetFile(
f.getPrivateAccess() ? String.format("%s/files/cscs?url=%s", Translator.fileProxy, f.getAbsolutePath()) : f.getAbsolutePath(),
f.getPrivateAccess() ? String.format("%s?url=%s", Translator.fileProxy, f.getAbsolutePath()) : f.getAbsolutePath(),
f.getPrivateAccess() ? String.format("ACCESS PROTECTED: %s", f.getName()) : f.getName(),
f.getHumanReadableSize(),
getFileImage(f.getStaticImageUrl(), false),
Expand Down Expand Up @@ -251,9 +251,9 @@ public DatasetVersion translate(DatasetV1 datasetV1, DataStage dataStage, boolea
if (dataStage == DataStage.IN_PROGRESS && !datasetV1.isUseHDG()) {
if (containerUrl != null && containerUrl.startsWith("https://object.cscs.ch")) {
if (hasEmbargoStatus(datasetV1, EMBARGOED)) {
d.setEmbargoRestrictedAccess(value(String.format("This dataset is temporarily under embargo. The data will become available for download after the embargo period.<br/><br/>If you are an authenticated user, <a href=\"https://kg.ebrains.eu/files/cscs/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", containerUrl)));
d.setEmbargoRestrictedAccess(value(String.format("This dataset is temporarily under embargo. The data will become available for download after the embargo period.<br/><br/>If you are an authenticated user, <a href=\"https://data.kg.ebrains.eu/files/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", containerUrl)));
} else if (hasEmbargoStatus(datasetV1, UNDER_REVIEW)) {
d.setEmbargoRestrictedAccess(value(String.format("This dataset is currently reviewed by the Data Protection Office regarding GDPR compliance. The data will be available after this review.<br/><br/>If you are an authenticated user, <a href=\"https://kg.ebrains.eu/files/cscs/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", containerUrl)));
d.setEmbargoRestrictedAccess(value(String.format("This dataset is currently reviewed by the Data Protection Office regarding GDPR compliance. The data will be available after this review.<br/><br/>If you are an authenticated user, <a href=\"https://data.kg.ebrains.eu/files/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", containerUrl)));
}
} else {
if (hasEmbargoStatus(datasetV1, EMBARGOED)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public ModelVersion translate(ModelV2 modelV2, DataStage dataStage, boolean live
if (fileBundle != null) {
String fileUrl = fileBundle.getUrl();
if (StringUtils.isNotBlank(fileUrl) && fileUrl.startsWith("https://object.cscs.ch")) {
m.setEmbargo(value(String.format("This model is temporarily under embargo. The data will become available for download after the embargo period.<br/><br/>If you are an authenticated user, <a href=\"https://kg.ebrains.eu/files/cscs/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", fileUrl)));
m.setEmbargo(value(String.format("This model is temporarily under embargo. The data will become available for download after the embargo period.<br/><br/>If you are an authenticated user, <a href=\"https://data.kg.ebrains.eu/files/list?url=%s\" target=\"_blank\"> you should be able to access the data here</a>", fileUrl)));
} else {
m.setEmbargo(value("This model is temporarily under embargo. The data will become available for download after the embargo period."));
}
Expand All @@ -105,7 +105,7 @@ public ModelVersion translate(ModelV2 modelV2, DataStage dataStage, boolean live
.map(fb -> {
if (fb.getUrl().startsWith("https://object.cscs.ch")) {
return new TargetExternalReference(
String.format("https://kg.ebrains.eu/proxy/export?container=%s", fb.getUrl()),
String.format("https://data.kg.ebrains.eu/zip?container=%s", fb.getUrl()),
"download all related data as ZIP" // TODO: Capitalize the value
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public Sample translate(SampleV1 sample, DataStage dataStage, boolean liveMode,
if (!hasEmbargoStatus(sample, EMBARGOED) && !StringUtils.isBlank(containerUrl) && !CollectionUtils.isEmpty(sample.getFiles())) {
if (containerUrl.startsWith("https://object.cscs.ch")) {
s.setAllFiles(new TargetExternalReference(
String.format("https://kg.ebrains.eu/proxy/export?container=%s", containerUrl),
String.format("https://data.kg.ebrains.eu/zip?container=%s", containerUrl),
"download all related data as ZIP"
));
} else {
Expand All @@ -153,7 +153,7 @@ public Sample translate(SampleV1 sample, DataStage dataStage, boolean liveMode,
.filter(v -> v.getAbsolutePath() != null && v.getName() != null)
.map(f ->
new TargetFile(
f.getPrivateAccess() ? String.format("%s/files/cscs?url=%s", Translator.fileProxy, f.getAbsolutePath()) : f.getAbsolutePath(),
f.getPrivateAccess() ? String.format("%s?url=%s", Translator.fileProxy, f.getAbsolutePath()) : f.getAbsolutePath(),
f.getPrivateAccess() ? String.format("ACCESS PROTECTED: %s", f.getName()) : f.getName(),
f.getHumanReadableSize(),
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public File translate(FileV3 file, DataStage dataStage, boolean liveMode, DOICit
if(!CollectionUtils.isEmpty(file.getServiceLinks())){
f.setViewer(file.getServiceLinks().stream().sorted(Comparator.comparing(ServiceLink::displayLabel)).map(s -> new TargetExternalReference(s.getUrl(), String.format("Open %s in %s", s.getLabel(), s.getService()))).collect(Collectors.toList()));
}
String iri = file.isPrivateAccess() ? String.format("%s/files/cscs?url=%s", Translator.fileProxy, file.getIri()) : file.getIri();
String iri = file.isPrivateAccess() ? String.format("%s?url=%s", Translator.fileProxy, file.getIri()) : file.getIri();
if (StringUtils.isNotBlank(iri)) {
f.setIri(new TargetExternalReference(iri, iri));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class DatasetVersion implements TargetInstance, VersionedInstance{
public final static String RESTRICTED_ACCESS_MESSAGE = "This dataset has restricted access. Although the metadata is publicly available, the data remain on an access restricted server.";

public static String createEmbargoInProgressMessage(String containerUrl){
String endpoint = Helpers.isDataProxyBucket(containerUrl) ? containerUrl.replaceAll("api/buckets/", "") : String.format("https://kg.ebrains.eu/files/cscs/list?url=%s", containerUrl);
String endpoint = Helpers.isDataProxyBucket(containerUrl) ? containerUrl.replaceAll("api/buckets/", "") : String.format("https://data.kg.ebrains.eu/files/list?url=%s", containerUrl);
return String.format("This dataset is temporarily under embargo. The data will become available for download after the embargo period.<br/><br/>If you are an authenticated user, <a href=\"%s\" target=\"_blank\"> you should be able to access the data here</a>", endpoint);
}

Expand Down
Loading

0 comments on commit 0a2e0c9

Please sign in to comment.