moved graphdb repository name and other properties in application.properties

This commit is contained in:
Enrico Ottonello 2019-12-16 14:46:42 +01:00
parent 0f6f2e7b75
commit b3d8a9193b
4 changed files with 25 additions and 9 deletions

View File

@ -35,14 +35,16 @@ public class GraphDBClient {
private String graphDBBaseURI;
private String writerUser;
private String writerPwd;
private String repository;
protected GraphDBClient(final RecordParserHelper recordParserHelper,
final String graphDBServerUrl, final String graphDBBaseURI, final String writerUser, final String writerPwd) {
final String graphDBServerUrl, final String graphDBBaseURI, final String writerUser, final String writerPwd, final String repository) {
this.recordParserHelper = recordParserHelper;
this.graphDBServerUrl = graphDBServerUrl;
this.graphDBBaseURI = graphDBBaseURI;
this.writerUser = writerUser;
this.writerPwd = writerPwd;
this.repository = repository;
}
public long feed(final String record) throws AriadnePlusPublisherException{
@ -57,7 +59,7 @@ public class GraphDBClient {
manager.init();
manager.setUsernameAndPassword(getWriterUser(), getWriterPwd());
log.debug("manager init");
Repository repository = manager.getRepository("ariadneprova");
Repository repository = manager.getRepository(getRepository());
ValueFactory factory = repository.getValueFactory();
String dsInterface = recordParserHelper.getDatasourceApi(record);
IRI graph = factory.createIRI(dsInterface);
@ -91,9 +93,9 @@ public class GraphDBClient {
log.debug("init connection to graphDBServerUrl " + this.graphDBServerUrl);
RemoteRepositoryManager manager = new RemoteRepositoryManager(this.graphDBServerUrl);
manager.init();
manager.setUsernameAndPassword("writer", "writer01");
manager.setUsernameAndPassword(getWriterUser(), getWriterPwd());
log.debug("manager init");
Repository repository = manager.getRepository("ariadneprova");
Repository repository = manager.getRepository(getRepository());
ValueFactory factory = repository.getValueFactory();
IRI IS_API_OF = factory.createIRI(PROVENANCE_NS, "isApiOf");
IRI INSERTED_IN_DATE = factory.createIRI(PROVENANCE_NS, "insertedInDate");
@ -232,6 +234,16 @@ public class GraphDBClient {
public void setWriterPwd(String writerPwd) {
this.writerPwd = writerPwd;
}
public String getRepository() {
return repository;
}
public void setRepository(String repository) {
this.repository = repository;
}
}
//

View File

@ -25,13 +25,15 @@ public class GraphDBClientFactory {
private String writerUser;
@Value("${graphdb.writer.pwd}")
private String writerPwd;
@Value("${graphdb.repository}")
private String repository;
@Autowired
private RecordParserHelper recordParserHelper;
public GraphDBClient getGraphDBClient() {
log.debug("Creating GraphDBClient for "+graphDBServerUrl);
return new GraphDBClient(recordParserHelper, graphDBServerUrl, graphDBBaseURI, writerUser, writerPwd);
return new GraphDBClient(recordParserHelper, graphDBServerUrl, graphDBBaseURI, writerUser, writerPwd, repository);
}
public RecordParserHelper getRecordParserHelper() {

View File

@ -4,6 +4,7 @@ server.port=8281
graphdb.serverUrl=http://localhost:7200/
graphdb.writer.user=writer
graphdb.writer.pwd=writer01
graphdb.repository=ariadneprova
graphdb.sparqlUrl = http://localhost:7200/sparql
graphdb.baseURI=https://ariadne-infrastructure.eu/
graphdb.baseURI=https://ariadne-infrastructure.eu/

View File

@ -2,11 +2,12 @@
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="SAVE-TO-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<file>/var/log/ariadneplus_graphdb/ariadneplus_graphdb.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>log_%d{dd-MM-yyyy}_%i.log</fileNamePattern>
<fileNamePattern>/var/log/ariadneplus_graphdb/ariadneplus_graphdb_%d{dd-MM-yyyy}_%i.log</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>10</maxHistory>
<totalSizeCap>100MB</totalSizeCap>