Skip to content

Commit

Permalink
Allow Bases with rdf:nil or null next pages (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
berezovskyi committed Jun 7, 2021
1 parent 3363977 commit 37147dc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
### Fixed

- Make sure every Lyo dependency uses the same version of Guava (30.0)
- Fix a few issues around rdf:nil handling in the TRS Client

## [4.0.0] - 2020-12-16

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.eclipse.lyo.trs.client.config;

import java.net.URI;

public final class TrsProviderConfiguration {
private final URI trsUri;
private final String basicAuthUsername;
private final String basicAuthPassword;

public final URI getTrsUri() {
return this.trsUri;
}

public final String getBasicAuthUsername() {
return this.basicAuthUsername;
}

public final String getBasicAuthPassword() {
return this.basicAuthPassword;
}

public TrsProviderConfiguration(URI trsUri, String basicAuthUsername, String basicAuthPassword) {
super();
this.trsUri = trsUri;
this.basicAuthUsername = basicAuthUsername;
this.basicAuthPassword = basicAuthPassword;
}

public static final TrsProviderConfiguration forHttp(String trsEndpointUri) {
URI trsUri = URI.create(trsEndpointUri);
return new TrsProviderConfiguration(trsUri, null, null);
}

public static final TrsProviderConfiguration forHttpWithBasicAuth(String trsEndpointUri, String trsEndpointUsername, String trsEndpointPassword) {
URI trsUri = URI.create(trsEndpointUri);
return new TrsProviderConfiguration(trsUri, trsEndpointUsername, trsEndpointPassword);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.apache.jena.rdf.model.Model;
import org.apache.jena.vocabulary.RDF;
import org.eclipse.lyo.core.trs.Base;
Expand Down Expand Up @@ -98,6 +99,16 @@ public boolean fetchRemoteChangeLogs(ChangeLog currentChangeLog, List<ChangeLog>
break;
}
previousChangeLog = currentChangeLog.getPrevious();
if(previousChangeLog == null || URI.create(RDF.nil.getURI()).equals(previousChangeLog)) {
if(URI.create(RDF.nil.getURI()).equals(lastProcessedChangeEventUri)) {
log.debug("First ChangeLog page reached");
foundChangeEvent = true;
}
else {
log.error("Changelog read to the end without finding the cutoff event URI");
}
break;
}
currentChangeLog = trsClient.fetchRemoteChangeLog(previousChangeLog);
} else {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,20 @@ static Base extractBaseFromRdfModel(Model rdFModel) throws LyoModelException {
}

if (baseObj == null) {
// FIXME Andrew@2019-07-15: nulls
log.error("Base page object is null");
//FIXME nulls
// throw new IllegalStateException();
return null;
}

if (ProviderUtil.isNotEmptySingletonArray(nextPageArray) && nextPageArray[0] instanceof Page) {
nextPage = (Page) nextPageArray[0];
baseObj.setNextPage(nextPage);
log.debug("finished extracting base from rdf model");
return baseObj;
} else {
log.debug("Base page {} is the last one", baseObj.getAbout());
}
log.debug("finished extracting base from rdf model");
// FIXME Andrew@2019-07-15: nulls
return null;
return baseObj;
}

/**
Expand Down

This file was deleted.

0 comments on commit 37147dc

Please sign in to comment.