diff --git a/pom.xml b/pom.xml index 655133a..c793918 100644 --- a/pom.xml +++ b/pom.xml @@ -10,8 +10,10 @@ UTF-8 1.8 1.8 - ${project.version} - 3.6.0 + + ${project.version} + 3.6.0 + 2.25.1 @@ -53,13 +55,7 @@ - - com.j2bugzilla - j2bugzilla - 2.2.1 - - - + org.openrdf.sesame sesame-repository-sparql 4.1.1 @@ -67,17 +63,17 @@ org.eclipse.lyo oslc-trs - ${lyo.version} + ${version.lyo} org.eclipse.lyo.oslc4j.core oslc4j-core - ${lyo.version} + ${version.lyo} org.apache.jena jena-arq - ${jena.version} + ${version.jena} org.slf4j @@ -103,12 +99,11 @@ org.eclipse.lyo.clients - oslc-java-client - ${lyo.version} + oslc4j-client + ${version.lyo} - junit junit @@ -118,7 +113,7 @@ org.apache.jena jena-tdb - ${jena.version} + ${version.jena} test @@ -127,7 +122,17 @@ 1.7.25 test - + + org.glassfish.jersey.core + jersey-client + ${version.jersey} + + + com.j2bugzilla + j2bugzilla + 2.2.1 + test + diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/config/TrsConsumerConfiguration.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/config/TrsConsumerConfiguration.java index ebfeb69..d74e579 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/config/TrsConsumerConfiguration.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/config/TrsConsumerConfiguration.java @@ -14,8 +14,11 @@ package org.eclipse.lyo.oslc4j.trs.client.config; +import com.google.common.base.Strings; import java.util.concurrent.ScheduledExecutorService; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; +import javax.ws.rs.client.ClientBuilder; +import org.eclipse.lyo.oslc4j.client.OslcClient; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; /** * Created on 2018-02-27 @@ -29,20 +32,24 @@ public class TrsConsumerConfiguration { private final String sparqlUpdateUrl; private final String sparqlUsername; private final String sparqlPassword; - private final TrsBasicAuthOslcClient httpClient; private final String mqttClientId; private final ScheduledExecutorService scheduler; + private final String basicUsername; + private final String basicPassword; + private OslcClient httpClient; public TrsConsumerConfiguration(final String sparqlQueryUrl, final String sparqlUpdateUrl, - final String sparqlUsername, final String sparqlPassword, final TrsBasicAuthOslcClient httpClient, - final String mqttClientId, final ScheduledExecutorService scheduler) { + final String sparqlUsername, final String sparqlPassword, final String mqttClientId, + final ScheduledExecutorService scheduler, final String basicUsername, + final String basicPassword) { this.sparqlQueryUrl = sparqlQueryUrl; this.sparqlUpdateUrl = sparqlUpdateUrl; this.sparqlUsername = sparqlUsername; this.sparqlPassword = sparqlPassword; - this.httpClient = httpClient; this.mqttClientId = mqttClientId; this.scheduler = scheduler; + this.basicUsername = basicUsername; + this.basicPassword = basicPassword; } public ScheduledExecutorService getScheduler() { @@ -69,7 +76,14 @@ public String getSparqlPassword() { return sparqlPassword; } - public TrsBasicAuthOslcClient getHttpClient() { + public OslcClient getHttpClient() { + if (httpClient == null) { + final ClientBuilder builder = ClientBuilder.newBuilder(); + if (!Strings.isNullOrEmpty(basicUsername)) { + builder.register(HttpAuthenticationFeature.basic(basicUsername, basicPassword)); + } + new OslcClient(builder); + } return httpClient; } } diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointConfigException.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointConfigException.java index 755b351..c0017ef 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointConfigException.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointConfigException.java @@ -1,6 +1,5 @@ package org.eclipse.lyo.oslc4j.trs.client.exceptions; -import org.apache.wink.client.ClientResponse; /** * TRS Client has a wrong configuration of a TRS Server endpoint. @@ -25,10 +24,6 @@ public TrsEndpointConfigException(final Throwable cause) { super(cause); } - public TrsEndpointConfigException(final ClientResponse response) { - super(response); - } - protected TrsEndpointConfigException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointErrorExpection.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointErrorExpection.java index 553d18c..988c386 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointErrorExpection.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointErrorExpection.java @@ -1,6 +1,5 @@ package org.eclipse.lyo.oslc4j.trs.client.exceptions; -import org.apache.wink.client.ClientResponse; /** * TRS Server endpoint returns a server error. @@ -25,10 +24,6 @@ public TrsEndpointErrorExpection(final Throwable cause) { super(cause); } - public TrsEndpointErrorExpection(final ClientResponse response) { - super(response); - } - protected TrsEndpointErrorExpection(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointException.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointException.java index 209a59d..a091ec9 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointException.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/exceptions/TrsEndpointException.java @@ -1,6 +1,6 @@ package org.eclipse.lyo.oslc4j.trs.client.exceptions; -import org.apache.wink.client.ClientResponse; +import javax.xml.ws.Response; /** * High-level exception for connection problems to the TRS Server endpoints. @@ -10,40 +10,25 @@ */ public class TrsEndpointException extends Exception { - private final ClientResponse response; - public TrsEndpointException() { super(); - response = null; } public TrsEndpointException(final String message) { super(message); - response = null; } public TrsEndpointException(final String message, final Throwable cause) { super(message, cause); - response = null; } public TrsEndpointException(final Throwable cause) { super(cause); - response = null; - } - - public TrsEndpointException(final ClientResponse response) { - super(); - this.response = response; } protected TrsEndpointException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); - response = null; } - public ClientResponse getResponse() { - return response; - } } diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/BaseMemberHandler.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/BaseMemberHandler.java index 9894dae..79e7330 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/BaseMemberHandler.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/BaseMemberHandler.java @@ -20,10 +20,9 @@ import java.net.URISyntaxException; import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import net.oauth.OAuthException; import org.apache.jena.rdf.model.Model; +import org.eclipse.lyo.oslc4j.client.OslcClient; import org.eclipse.lyo.oslc4j.trs.client.util.SparqlUtil; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +34,7 @@ */ public class BaseMemberHandler extends TRSTaskHandler { - final static Logger logger = LoggerFactory.getLogger(BaseMemberHandler.class); + private final static Logger logger = LoggerFactory.getLogger(BaseMemberHandler.class); /* * the uri of the base member to be processed */ String baseMemberUri; @@ -47,9 +46,9 @@ public class BaseMemberHandler extends TRSTaskHandler { * the size of the rdf representation of the rdf member */ AtomicLong modelSize; - public BaseMemberHandler(TrsBasicAuthOslcClient oslcClient, String sparqlQueryService, - String sparqlUpdateService, String baseAuth_userName, String baseAuth_pwd, - String baseMemberUri, List queries, AtomicLong modelSize) { + public BaseMemberHandler(String baseMemberUri, List queries, AtomicLong modelSize, + OslcClient oslcClient, String sparqlQueryService, String sparqlUpdateService, String baseAuth_userName, + String baseAuth_pwd) { // TODO Andrew@2018-03-01: use a common SPARQL interface super(oslcClient, sparqlQueryService, @@ -69,7 +68,7 @@ public BaseMemberHandler(TrsBasicAuthOslcClient oslcClient, String sparqlQuerySe protected void processTRSTask() { try { processBaseMemberAddition(); - } catch (IOException | OAuthException | URISyntaxException e) { + } catch (IOException | URISyntaxException e) { logger.error("Error processing TRS task", e); } } @@ -78,7 +77,7 @@ protected void processTRSTask() { * create the necessary sparql update for processing the base member */ private void processBaseMemberAddition() - throws IOException, OAuthException, URISyntaxException { + throws IOException, URISyntaxException { logger.debug("processing base member " + baseMemberUri + " addition. Creating necessary " + "" + "" + "sparql update query "); diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ChangeEventHandler.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ChangeEventHandler.java index 4859ac6..df1bdb5 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ChangeEventHandler.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ChangeEventHandler.java @@ -21,12 +21,11 @@ import java.net.URISyntaxException; import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import net.oauth.OAuthException; import org.apache.jena.rdf.model.Model; import org.eclipse.lyo.core.trs.ChangeEvent; import org.eclipse.lyo.core.trs.Deletion; +import org.eclipse.lyo.oslc4j.client.OslcClient; import org.eclipse.lyo.oslc4j.trs.client.util.SparqlUtil; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,9 +52,9 @@ public class ChangeEventHandler extends TRSTaskHandler { */ AtomicLong modelSize; - public ChangeEventHandler(TrsBasicAuthOslcClient oslcClient, String sparqlQueryService, - String sparqlUpdateService, String basicAuthUsername, String basicAuthPassword, - ChangeEvent handledChangeEvent, List queries, AtomicLong modelSize) { + public ChangeEventHandler(ChangeEvent handledChangeEvent, List queries, + AtomicLong modelSize, OslcClient oslcClient, String sparqlUpdateService, String sparqlQueryService, + String basicAuthUsername, String basicAuthPassword) { // here we assume the triplestore is not auth-protected, hence nulls super(oslcClient, sparqlUpdateService, @@ -73,7 +72,7 @@ public ChangeEventHandler(TrsBasicAuthOslcClient oslcClient, String sparqlQueryS this.modelSize = modelSize; } - private void processChangeEvent() throws IOException, OAuthException, URISyntaxException { + private void processChangeEvent() throws IOException, URISyntaxException { URI changed = handledChangeEvent.getChanged(); logger.debug("creating query for resource " + changed.toString() + " change event "); String query; @@ -105,7 +104,7 @@ private void processChangeEvent() throws IOException, OAuthException, URISyntaxE protected void processTRSTask() { try { processChangeEvent(); - } catch (IOException | OAuthException | URISyntaxException e) { + } catch (IOException | URISyntaxException e) { logger.error("Error processing Change Events", e); } } diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ConcurrentTrsProviderHandler.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ConcurrentTrsProviderHandler.java index 1e3ea39..a2b736e 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ConcurrentTrsProviderHandler.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/ConcurrentTrsProviderHandler.java @@ -28,16 +28,15 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import net.oauth.OAuthException; import org.eclipse.lyo.core.trs.Base; import org.eclipse.lyo.core.trs.ChangeEvent; import org.eclipse.lyo.core.trs.ChangeLog; import org.eclipse.lyo.core.trs.TrackedResourceSet; +import org.eclipse.lyo.oslc4j.client.OslcClient; import org.eclipse.lyo.oslc4j.trs.client.exceptions.JenaModelException; import org.eclipse.lyo.oslc4j.trs.client.exceptions.ServerRollBackException; import org.eclipse.lyo.oslc4j.trs.client.exceptions.RepresentationRetrievalException; import org.eclipse.lyo.oslc4j.trs.client.util.SparqlUtil; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,25 +53,19 @@ public class ConcurrentTrsProviderHandler extends TrsProviderHandler { private final static Logger log = LoggerFactory.getLogger(ConcurrentTrsProviderHandler.class); public ConcurrentTrsProviderHandler(String trsUriBase, String sparqlQueryService, - String sparqlUpdateService, TrsBasicAuthOslcClient trsHttpClient, String userName, + String sparqlUpdateService, OslcClient client, String userName, String pwd, String sparql_user, String sparql_pwd) { super( - trsUriBase, - sparqlQueryService, - sparqlUpdateService, - trsHttpClient, - userName, - pwd, - sparql_user, - sparql_pwd - ); + trsUriBase, client, sparqlUpdateService, sparqlQueryService, sparql_user, + sparql_pwd, userName, + pwd); } @Override public void pollAndProcessChanges() throws URISyntaxException, JenaModelException, IOException, ServerRollBackException, - RepresentationRetrievalException, OAuthException { + RepresentationRetrievalException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); Date processingDateStart = new Date(); log.info("started dealing with TRS Provider: " + trsUriBase); @@ -123,30 +116,20 @@ COMMON CODE END (with TRS provider handler) for (URI baseMemberUri : baseMembers) { BaseMemberHandler baseMemberHandler = new BaseMemberHandler( - oslcClient, + baseMemberUri.toString(), queries, modelSize, oslcClient, sparqlQueryService, sparqlUpdateService, baseAuth_userName, - baseAuth_pwd, - baseMemberUri.toString(), - queries, - modelSize - ); + baseAuth_pwd); changeHandlerExecutor.execute(baseMemberHandler); } } for (ChangeEvent compressedChangeEvent : compressedChanges) { - ChangeEventHandler changeEventHandler = new ChangeEventHandler( - oslcClient, - sparqlQueryService, - sparqlUpdateService, + ChangeEventHandler changeEventHandler = new ChangeEventHandler(compressedChangeEvent, + queries, modelSize, oslcClient, sparqlUpdateService, sparqlQueryService, baseAuth_userName, - baseAuth_pwd, - compressedChangeEvent, - queries, - modelSize - ); + baseAuth_pwd); changeHandlerExecutor.execute(changeEventHandler); lastProcessedChangeEventUri = compressedChangeEvent.getAbout(); } diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TRSTaskHandler.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TRSTaskHandler.java index 32fe007..21ca645 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TRSTaskHandler.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TRSTaskHandler.java @@ -18,9 +18,11 @@ import java.io.IOException; import java.net.URISyntaxException; -import net.oauth.OAuthException; -import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointException; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; +import javax.ws.rs.core.Response; +import org.eclipse.lyo.oslc4j.client.OslcClient; +import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointConfigException; +import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointErrorExpection; +import org.eclipse.lyo.oslc4j.trs.client.util.ClientUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +41,7 @@ public abstract class TRSTaskHandler implements Runnable { * instance of the http client used by this TRS Task handler to communicate * with the TRS providers */ - protected TrsBasicAuthOslcClient oslcClient; + protected OslcClient oslcClient; /** * http sparql endpoints of the triplestore used to store the data */ @@ -76,19 +78,24 @@ public abstract class TRSTaskHandler implements Runnable { * @throws IOException */ protected Object fetchTRSRemoteResource(String url, Class objClass) - throws IOException, OAuthException, URISyntaxException { + throws IOException, URISyntaxException { + final Response response = oslcClient.getResource(url); + final Object resource; try { - return oslcClient.fetchResourceUsingBaseAuth( - url, objClass, baseAuth_userName, baseAuth_pwd); - } catch (TrsEndpointException e) { - log.error("The TRS endpoint {} is unreachable", url); - log.trace("TRS endpoint exception: {}", e); - // TODO Andrew@2018-06-19: propagate the exception correctly to callers. - return null; + resource = ClientUtil.extractResourceFromResponse(response, objClass); + response.close(); + return resource; + } catch (TrsEndpointConfigException e) { + log.error("TRS Provider configuration is wrong: ", e); + } catch (TrsEndpointErrorExpection e) { + log.warn("The TRS endpoint {} is unreachable", url); + log.debug("TRS endpoint exception", e); } + // TODO Andrew@2019-04-18: convert return type into Optional + throw new IllegalStateException(); } - public TRSTaskHandler(TrsBasicAuthOslcClient oslcClient, String sparqlUpdateService, String sparqlQueryService, + public TRSTaskHandler(OslcClient oslcClient, String sparqlUpdateService, String sparqlQueryService, String sparql_baseAuth_userName, String sparql_baseAuth_pwd, String baseAuth_userName, String baseAuth_pwd) { super(); diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandler.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandler.java index d1b0d4f..66e4a07 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandler.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandler.java @@ -30,10 +30,8 @@ import java.util.Set; import java.util.stream.Collectors; import javax.xml.datatype.DatatypeConfigurationException; -import net.oauth.OAuthException; import org.apache.jena.rdf.model.Model; import org.apache.jena.vocabulary.RDF; -import org.apache.wink.client.ClientRuntimeException; import org.eclipse.lyo.core.trs.Base; import org.eclipse.lyo.core.trs.ChangeEvent; import org.eclipse.lyo.core.trs.ChangeLog; @@ -42,6 +40,7 @@ import org.eclipse.lyo.core.trs.Modification; import org.eclipse.lyo.core.trs.Page; import org.eclipse.lyo.core.trs.TrackedResourceSet; +import org.eclipse.lyo.oslc4j.client.OslcClient; import org.eclipse.lyo.oslc4j.core.exception.OslcCoreApplicationException; import org.eclipse.lyo.oslc4j.core.model.AbstractResource; import org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper; @@ -50,7 +49,6 @@ import org.eclipse.lyo.oslc4j.trs.client.util.ChangeEventComparator; import org.eclipse.lyo.oslc4j.trs.client.exceptions.RepresentationRetrievalException; import org.eclipse.lyo.oslc4j.trs.client.util.SparqlUtil; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,10 +78,10 @@ public class TrsProviderHandler extends TRSTaskHandler { /** * @param sparqlUpdateService Set to null to disable the triplestore update */ - public TrsProviderHandler(String trsUriBase, String sparqlQueryService, - String sparqlUpdateService, TrsBasicAuthOslcClient trsHttpClient, String providerUsername, - String providerPassword, String sparqlUsername, String sparqlPassword) { - super(trsHttpClient, + public TrsProviderHandler(String trsUriBase, OslcClient client, + String sparqlUpdateService, String sparqlQueryService, String sparqlUsername, + String sparqlPassword, String providerUsername, String providerPassword) { + super(client, sparqlUpdateService, sparqlQueryService, sparqlUsername, @@ -138,7 +136,7 @@ protected void processTRSTask() { * @return the pages of the base of this trs provider */ public List updateBases(TrackedResourceSet updatedTrs) - throws JenaModelException, IOException, OAuthException, URISyntaxException { + throws JenaModelException, IOException, URISyntaxException { List bases = new ArrayList<>(); URI firstBasePageUri = updatedTrs.getBase(); Base currentBase = fetchRemoteBase(firstBasePageUri.toString()); @@ -168,7 +166,7 @@ public List updateBases(TrackedResourceSet updatedTrs) * @return the pages of the change log of this trs provider */ public List fetchUpdatedChangeLogs(TrackedResourceSet updatedTrs) - throws ServerRollBackException, IOException, JenaModelException, OAuthException, + throws ServerRollBackException, IOException, JenaModelException, URISyntaxException { ChangeLog firstChangeLog = updatedTrs.getChangeLog(); @@ -201,7 +199,7 @@ public List fetchUpdatedChangeLogs(TrackedResourceSet updatedTrs) * @return true if the last processed change event is found, false otherwise */ public boolean fetchRemoteChangeLogs(ChangeLog currentChangeLog, List changeLogs) - throws JenaModelException, IOException, OAuthException, URISyntaxException { + throws JenaModelException, IOException, URISyntaxException { boolean foundChangeEvent = false; URI previousChangeLog; do { @@ -274,17 +272,11 @@ protected void baseChangeEventsOptimization(List compressedChangesL */ public void pollAndProcessChanges() throws URISyntaxException, JenaModelException, IOException, ServerRollBackException, - RepresentationRetrievalException, OAuthException { + RepresentationRetrievalException { log.info("started dealing with TRS Provider: " + trsUriBase); - TrackedResourceSet updatedTrs = null; - try { - updatedTrs = extractRemoteTrs(); - } catch (ClientRuntimeException e) { - log.warn("Failed to connect to {}", trsUriBase); - return; - } + TrackedResourceSet updatedTrs = extractRemoteTrs(); boolean indexingStage = false; List baseMembers = new ArrayList<>(); @@ -379,7 +371,7 @@ concurrent handler does it first (though the change handlers don't wait for the * @param changeEvent the change event to be processed */ public void processChangeEvent(ChangeEvent changeEvent) - throws IOException, OAuthException, URISyntaxException { + throws IOException, URISyntaxException { URI changed = changeEvent.getChanged(); log.info("processing resource " + changed.toString() + " change event "); @@ -667,7 +659,7 @@ private Base extractBaseFromRdfModel(Model rdFModel) throws JenaModelException { * @return trs pojo */ TrackedResourceSet extractRemoteTrs() - throws IOException, JenaModelException, URISyntaxException, OAuthException { + throws IOException, JenaModelException, URISyntaxException { Model rdfModel = (Model) fetchTRSRemoteResource(trsUriBase, Model.class); return extractTrsFromRdfModel(rdfModel); } @@ -682,7 +674,7 @@ TrackedResourceSet extractRemoteTrs() */ private ChangeLog fetchRemoteChangeLog(String changeLogURl) throws IOException, IllegalArgumentException, SecurityException, JenaModelException, - OAuthException, URISyntaxException { + URISyntaxException { Model rdfModel = (Model) fetchTRSRemoteResource(changeLogURl, Model.class); return extractChangeLogFromRdfModel(rdfModel); } @@ -696,7 +688,7 @@ private ChangeLog fetchRemoteChangeLog(String changeLogURl) * @return base pojo */ private Base fetchRemoteBase(String baseUrl) - throws IOException, JenaModelException, OAuthException, URISyntaxException { + throws IOException, JenaModelException, URISyntaxException { final Model rdFModel = (Model) fetchTRSRemoteResource(baseUrl, Model.class); return extractBaseFromRdfModel(rdFModel); } diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/misc/BugzillaConnect.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/misc/BugzillaConnect.java deleted file mode 100644 index fdf87e1..0000000 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/misc/BugzillaConnect.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2016-2018 KTH Royal Institute of Technology. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v. 1.0 which accompanies this distribution. - * - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * - * Omar Kacimi - Initial implementation - * Andrew Berezovskyi - Lyo contribution updates - */ -package org.eclipse.lyo.oslc4j.trs.client.misc; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; - -/** - * * connecting to bugzilla through java xml-rpc api and that could be used to - * generate random bug data. - * - * @author Omar - * - */ -public class BugzillaConnect { - - private static final String serverUrl = "http://10.238.2.145/xmlrpc.cgi"; - private static final String adminUser = ""; - private static final String adminPassword = ""; - private static final String assigneeUser = "omar.kacimi@gmail.com"; - - public static void main(String[] args) throws MalformedURLException { - - XmlRpcClient client = new XmlRpcClient(); - XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - - // Setting timeouts for xmlrpc calls made using - // XmlRpcSunHttpTransportFactory, the default connection factory int - int xmlrpcConnTimeout = 120000; // Connection timeout - int xmlrpcReplyTimeOut = 120000; // Reply timeout - - config.setServerURL(new URL(serverUrl)); - config.setConnectionTimeout(xmlrpcConnTimeout); - config.setReplyTimeout(xmlrpcReplyTimeOut); - client.setConfig(config); - - login(client, adminUser, adminPassword); - - createBug(client); - } - - private static void login(XmlRpcClient client, String name, String password) { - try { - // map of the login data - Map loginMap = new HashMap(); - loginMap.put("login", name); - loginMap.put("password", password); - - // login to bugzilla - Map loginResult = (Map) client.execute("User.login", new Object[] { loginMap }); - System.out.println(name + " logged in, id=" + loginResult.get("id")); - } catch (XmlRpcException e) { - System.out.println(name + ": error " + e.code); - } - } - - private static void createBug(XmlRpcClient client) { - long time = System.nanoTime(); - try { - // map of the bug data - Map bugMap = new HashMap(); - - bugMap.put("product", "TestProduct"); - bugMap.put("component", "TestComponent"); - bugMap.put("summary", "A bug with a specific assignee"); - bugMap.put("description", "This will be a comment"); - bugMap.put("version", "unspecified"); - bugMap.put("op_sys", "Linux"); - bugMap.put("platform", "PC"); - bugMap.put("assigned_to", assigneeUser); - - // create bug - Object createResult = client.execute("Bug.create", new Object[] { bugMap }); - System.out.println("createResult = " + createResult); - } catch (XmlRpcException e) { - System.out.println("Creation error: " + e.code); - System.out.println(e.getMessage()); - } - System.out.println((System.nanoTime() - time) / 1000000); - } -} diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/ClientUtil.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/ClientUtil.java new file mode 100644 index 0000000..cd4f1ea --- /dev/null +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/ClientUtil.java @@ -0,0 +1,85 @@ +package org.eclipse.lyo.oslc4j.trs.client.util; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import javax.ws.rs.core.Response; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; +import org.eclipse.lyo.oslc4j.core.model.AbstractResource; +import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointConfigException; +import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointErrorExpection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * TODO + * + * @since TODO + */ +public class ClientUtil { + + private final static Logger log = LoggerFactory.getLogger(ClientUtil.class); + + public static Object extractResourceFromResponse(final Response response, + final Class objClass) + throws TrsEndpointConfigException, TrsEndpointErrorExpection, IOException { + final Response.StatusType responseInfo = response.getStatusInfo(); + final Response.Status.Family httpCodeType = responseInfo.getFamily(); + if (httpCodeType.equals(Response.Status.Family.CLIENT_ERROR)) { + throw new TrsEndpointConfigException("Error " + responseInfo.getReasonPhrase()); + } else if (httpCodeType.equals(Response.Status.Family.SERVER_ERROR)) { + throw new TrsEndpointErrorExpection("Error " + responseInfo.getReasonPhrase()); + } + if (AbstractResource.class.isAssignableFrom(objClass)) { + Object objToRet = response.readEntity(objClass); + log.trace("Finished consuming content from server response"); + return objToRet; + } else if (Model.class.isAssignableFrom(objClass)) { + return extractModelFromResponse(response); + } + + throw new IllegalStateException("The resources could not be fetched"); + } + + /** + * Extract and return a Jena model from the response if possible + * + * @param clientResponse response object from which the rdf model is read + * + * @throws IOException thrown while reading from the response + */ + private static Model extractModelFromResponse(final Response clientResponse) + throws IOException { + + if (clientResponse == null) { + log.warn("The server response is null. Returning null"); + return null; + } + + final String responseAsString = clientResponse.readEntity(String.class); + log.trace("Response:\n{}\n", responseAsString); + + if (responseAsString == null) { + log.warn("The server response is null. Returning null"); + return null; + } + + log.trace("Creating Jena model from server response string"); + + final Model rdFModel = ModelFactory.createDefaultModel(); + + try (InputStream is = new ByteArrayInputStream(responseAsString.getBytes())) { + rdFModel.read(is, null); + } + + log.trace("OK! Created Jena model from server response string"); + + if (!rdFModel.isEmpty() && log.isDebugEnabled()) { + log.debug("Created model contains {} statements", rdFModel.size()); + } + + return rdFModel; + } + +} diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/TrsBasicAuthOslcClient.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/TrsBasicAuthOslcClient.java deleted file mode 100644 index ba65042..0000000 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/TrsBasicAuthOslcClient.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2016-2018 KTH Royal Institute of Technology. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and Eclipse Distribution License v. 1.0 which accompanies this distribution. - * - * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html - * and the Eclipse Distribution License is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * Contributors: - * - * Omar Kacimi - Initial implementation - * Andrew Berezovskyi - Lyo contribution updates - */ -package org.eclipse.lyo.oslc4j.trs.client.util; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; -import javax.ws.rs.core.Response; -import net.oauth.OAuthException; -import org.apache.commons.codec.binary.Base64; -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.wink.client.ClientResponse; -import org.eclipse.lyo.client.oslc.jazz.JazzFormAuthClient; -import org.eclipse.lyo.oslc4j.core.model.AbstractResource; -import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointConfigException; -import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointErrorExpection; -import org.eclipse.lyo.oslc4j.trs.client.exceptions.TrsEndpointException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The http client instance shared between all TRS Task handlers in the - * consumer. Provides methods allowing retrieval OSLC resources from an OSLC - * Provider using basic authentication and the return of a requested content - * type from the server response. Also supports the return of an rdf Jena model - * in case a model is requested - * - * @author Omar - */ -public class TrsBasicAuthOslcClient extends JazzFormAuthClient { - - private static Logger log = LoggerFactory.getLogger(TrsBasicAuthOslcClient.class); - - public TrsBasicAuthOslcClient() { - super(); - } - - /** - * call the getResourceUsingBaseAuth to retirve the response for the - * requested url and return a jena rdf model or an object of the requested - * class if possible - * - * @param url requested resource's url - * @param objClass requested content type - * @param userName usename for basic authentication - * @param pwd password for basic authentication - */ - public Object fetchResourceUsingBaseAuth(String url, Class objClass, String userName, - String pwd) - throws IOException, OAuthException, URISyntaxException, TrsEndpointException { - ClientResponse clResp = fetchResourceUsingBasicAuth(url, userName, pwd); - - final Response.Status.Family httpCodeType = clResp.getStatusType().getFamily(); - if (httpCodeType.equals(Response.Status.Family.CLIENT_ERROR)) { - throw new TrsEndpointConfigException(clResp); - } else if (httpCodeType.equals(Response.Status.Family.SERVER_ERROR)) { - throw new TrsEndpointErrorExpection(clResp); - } - // TODO Andrew@2018-02-28: split into 2 methods: unmarshalling a resource and for a model - if (AbstractResource.class.isAssignableFrom(objClass)) { - Object objToRet; - log.debug( - "Getting entity of type '{}' for server response for resource '{}'", - objClass.getName(), - url); - objToRet = clResp.getEntity(objClass); - log.debug( - "Getting entity of type '{}' for server response for resource '{}'", - objClass.getName(), - url); - clResp.consumeContent(); - log.trace("Finished consuming content from server response"); - return objToRet; - } else if (Model.class.isAssignableFrom(objClass)) { - log.debug("Getting jena model for server response for resource: " + url); - return extractModelFromResponse(url, clResp); - } - - throw new IllegalStateException("The resources could not be fetched"); - } - - /** - * using bastic authentication if possible retrieve the requested resource - * from the given url and return the retrieved http response - * - * @param url url of the requested resoruce - * @param userName username for basic authentication if application - * @param pwd pwd for basic authentication if applicable - * - * @return the http response from the server - */ - public ClientResponse fetchResourceUsingBasicAuth(String url, String userName, String pwd) - throws OAuthException, IOException, URISyntaxException { - log.debug("sending GET request to retrieve: " + url + " using basic credentials, user: " - + userName); - ClientResponse response = null; - Map requestHeaders = new HashMap(); -// requestHeaders.put("Accept", "application/rdf+xml, application/xml;q=0.6, text/xml; -// q=0.6"); - - if (userName != null && pwd != null && !userName.isEmpty() && !pwd.isEmpty()) { - String authenticationHeaderVal = userName + ":" + pwd; - String authentificationHeaderName = "Authorization"; - - byte[] authenticationHeaderValEncodedBytes = Base64.encodeBase64(authenticationHeaderVal - .getBytes()); - - String authenticationHeaderValEncoded = new String(authenticationHeaderValEncodedBytes); - String fullAuthenticationHeaderVal = "Basic " + authenticationHeaderValEncoded; - - requestHeaders.put(authentificationHeaderName, fullAuthenticationHeaderVal); - } - - response = super.getResource(url, requestHeaders); - log.debug("result of GET request for: " + url + " retrieved"); - return response; - } - - /** - * Extract and return a Jena model from the response if possible - * - * @param clientResponse response object from which the rdf model is read - * - * @throws IOException thrown while reading from the response - */ - public static Model extractModelFromResponse(String absoluteUrl, - final ClientResponse clientResponse) throws IOException { - - if (clientResponse == null) { - log.debug("The server response for url: " + absoluteUrl + " is null. Returning null"); - return null; - } - - final String responseAsString = clientResponse.getEntity(String.class); - log.trace("Response for {}:\n{}\n", absoluteUrl, responseAsString); - - if (responseAsString == null) { - log.debug("The server response for url: " + absoluteUrl + " is null. Returning null"); - return null; - } - - log.trace("Found entity of type String in the sever response for url: " + absoluteUrl + ". Creating a Jena Model and returning it."); - - final Model rdFModel = ModelFactory.createDefaultModel(); - - try (InputStream is = new ByteArrayInputStream(responseAsString.getBytes())) { - rdFModel.read(is, null); - } - - log.trace("successful created Jena model from response for url: ." + absoluteUrl + " . " - + "Returning the response"); - - if (!rdFModel.isEmpty()) { - log.debug("model extracted from response for url: ." + absoluteUrl + " has size: " + - rdFModel - .size() + " " + "statement"); - } - - return rdFModel; - } - -} diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/TrsConsumerUtils.java b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/TrsConsumerUtils.java index 381a850..a49273d 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/TrsConsumerUtils.java +++ b/src/main/java/org/eclipse/lyo/oslc4j/trs/client/util/TrsConsumerUtils.java @@ -18,7 +18,6 @@ package org.eclipse.lyo.oslc4j.trs.client.util; -import com.google.common.base.Strings; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -82,15 +81,10 @@ public static List buildHandlers( private static TrsProviderHandler providerFor(final TrsConsumerConfiguration consumerConfig, final TrsProviderConfiguration cfg) { - return new TrsProviderHandler(cfg.getTrsUri(), - consumerConfig.getSparqlQueryUrl(), - consumerConfig.getSparqlUpdateUrl(), - consumerConfig.getHttpClient(), - cfg.getBasicAuthUsername(), - cfg.getBasicAuthPassword(), - consumerConfig.getSparqlUsername(), - consumerConfig.getSparqlPassword() - ); + return new TrsProviderHandler(cfg.getTrsUri(), consumerConfig.getHttpClient(), + consumerConfig.getSparqlUpdateUrl(), consumerConfig.getSparqlQueryUrl(), + consumerConfig.getSparqlUsername(), consumerConfig.getSparqlPassword(), cfg.getBasicAuthUsername(), + cfg.getBasicAuthPassword()); } private static TrsProviderHandler concurrentProviderFor( diff --git a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/misc/ModelCreationUtil.java b/src/test/java/org/eclipse/lyo/oslc4j/trs/client/ModelCreationUtil.java similarity index 99% rename from src/main/java/org/eclipse/lyo/oslc4j/trs/client/misc/ModelCreationUtil.java rename to src/test/java/org/eclipse/lyo/oslc4j/trs/client/ModelCreationUtil.java index e1cbb06..ec7610f 100644 --- a/src/main/java/org/eclipse/lyo/oslc4j/trs/client/misc/ModelCreationUtil.java +++ b/src/test/java/org/eclipse/lyo/oslc4j/trs/client/ModelCreationUtil.java @@ -14,7 +14,7 @@ * Omar Kacimi - Initial implementation * Andrew Berezovskyi - Lyo contribution updates */ -package org.eclipse.lyo.oslc4j.trs.client.misc; +package org.eclipse.lyo.oslc4j.trs.client; import java.io.IOException; import java.util.ArrayList; @@ -48,8 +48,6 @@ import com.j2bugzilla.base.ConnectionException; import com.j2bugzilla.rpc.LogIn; import com.j2bugzilla.rpc.ReportBug; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * contains utility classes to create bugzilla bugs, and to link data in the diff --git a/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandlerTest.java b/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandlerTest.java index ee80dfa..b92a566 100644 --- a/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandlerTest.java +++ b/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderHandlerTest.java @@ -30,8 +30,7 @@ import org.eclipse.lyo.core.trs.Modification; import org.eclipse.lyo.core.trs.Page; import org.eclipse.lyo.core.trs.TrackedResourceSet; -import org.eclipse.lyo.oslc4j.trs.client.handlers.TrsProviderHandler; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; +import org.eclipse.lyo.oslc4j.client.OslcClient; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -184,7 +183,7 @@ private void initChangeEvent(ChangeEvent ce, String baseMemberUriString) throws private static String trsUriPrefix = uriPrefix + "/trackedResourceSets"; private void initChangeLog(ChangeLog cl, URI previous) throws URISyntaxException { - List changeEvents_p1 = new ArrayList(); + List changeEvents_p1 = new ArrayList<>(); Modification me_p1 = new Modification(); Creation ce_p1 = new Creation(); @@ -234,15 +233,9 @@ private void initChangeLog(ChangeLog cl, URI previous) throws URISyntaxException @BeforeClass public static void setUpBeforeClass() { - trsProvider = new TrsProviderHandler("", - "", - "", - new TrsBasicAuthOslcClient(), + trsProvider = new TrsProviderHandler("", new OslcClient(), "", "", null, null, null, - null, - null, - null - ); + null); trs = new TrackedResourceSet(); cl_p1 = new ChangeLog(); cl_p2 = new ChangeLog(); @@ -255,15 +248,9 @@ public static void setUpBeforeClass() { @After public void tearDown() { - trsProvider = new TrsProviderHandler("", - "", - "", - new TrsBasicAuthOslcClient(), + trsProvider = new TrsProviderHandler("", new OslcClient(), "", "", null, null, null, - null, - null, - null - ); + null); trs = new TrackedResourceSet(); cl_p1 = new ChangeLog(); cl_p2 = new ChangeLog(); @@ -337,7 +324,7 @@ private void initBase(Base base, URI previous) throws URISyntaxException { if (previous != null) { ldp.setAbout(URI.create(bUriPrefix + "/" //$NON-NLS-1$ - + String.valueOf(baseNum)));// ); + + baseNum));// ); ldp.setPageOf(base); ldp.setNextPage(previous); } else { diff --git a/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderTest.java b/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderTest.java index a04f48d..782ab46 100644 --- a/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderTest.java +++ b/src/test/java/org/eclipse/lyo/oslc4j/trs/client/handlers/TrsProviderTest.java @@ -30,8 +30,7 @@ import org.eclipse.lyo.core.trs.Modification; import org.eclipse.lyo.core.trs.Page; import org.eclipse.lyo.core.trs.TrackedResourceSet; -import org.eclipse.lyo.oslc4j.trs.client.handlers.TrsProviderHandler; -import org.eclipse.lyo.oslc4j.trs.client.util.TrsBasicAuthOslcClient; +import org.eclipse.lyo.oslc4j.client.OslcClient; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -43,8 +42,9 @@ public class TrsProviderTest { @BeforeClass - public static void setUpBeforeClass() throws Exception { - trsProvider = new TrsProviderHandler("", "", "", new TrsBasicAuthOslcClient(), "", "", null, null); + public static void setUpBeforeClass() { + trsProvider = new TrsProviderHandler("", new OslcClient(), "", "", null, null, + "", ""); trs = new TrackedResourceSet(); cl_p1 = new ChangeLog(); cl_p2 = new ChangeLog(); @@ -82,12 +82,13 @@ public void setUp() throws Exception { } @AfterClass - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterClass() { } @After - public void tearDown() throws Exception { - trsProvider = new TrsProviderHandler("", "", "", new TrsBasicAuthOslcClient(), "", "", null, null); + public void tearDown() { + trsProvider = new TrsProviderHandler("", new OslcClient(), "", "", null, null, + "", ""); trs = new TrackedResourceSet(); cl_p1 = new ChangeLog(); cl_p2 = new ChangeLog(); @@ -108,7 +109,7 @@ public final void testChangeLogContainsEvent() throws URISyntaxException { @Test public final void testBaseChangeEventsOptimization() { - List changeEventsList = new ArrayList(); + List changeEventsList = new ArrayList<>(); changeEventsList.add(creation); changeEventsList.add(modif); @@ -166,7 +167,7 @@ public final void testOptimizedChangesList() throws URISyntaxException { List changeEventsList = trsProvider.optimizedChangesList(changeLogsList); - Assert.assertTrue(changeEventsList.size() == 2); + Assert.assertEquals(2, changeEventsList.size()); Assert.assertTrue(changeEventsList.contains(memb1_d1)); Assert.assertTrue(changeEventsList.contains(memb2_m2)); @@ -225,7 +226,7 @@ private void initBase(Base base, URI previous) throws URISyntaxException { base.setCutoffEvent(new URI(changeEventUri())); - List b_p1_members = new ArrayList(); + List b_p1_members = new ArrayList<>(); b_p1_members.add(new URI(baseMemberUri())); b_p1_members.add(new URI(baseMemberUri())); b_p1_members.add(new URI(baseMemberUri())); @@ -234,7 +235,7 @@ private void initBase(Base base, URI previous) throws URISyntaxException { if (previous != null) { ldp.setAbout(URI.create(bUriPrefix + "/" //$NON-NLS-1$ - + String.valueOf(baseNum)));// ); + + baseNum));// ); ldp.setPageOf(base); ldp.setNextPage(previous); } else @@ -244,7 +245,7 @@ private void initBase(Base base, URI previous) throws URISyntaxException { } private void initChangeLog(ChangeLog cl, URI previous) throws URISyntaxException { - List changeEvents_p1 = new ArrayList(); + List changeEvents_p1 = new ArrayList<>(); Modification me_p1 = new Modification(); Creation ce_p1 = new Creation(); @@ -276,29 +277,28 @@ private void initChangeLog(ChangeLog cl, URI previous) throws URISyntaxException } } - static String uriPrefix = "https://host"; - - static String ceUriPrefix = uriPrefix + "/changeEvents"; - static String bmUriPrefix = uriPrefix + "/baseMembers"; - static String bUriPrefix = uriPrefix + "/bases"; - - static String clUriPrefix = uriPrefix + "/changeLogs"; - static String trsUriPrefix = uriPrefix + "/trackedResourceSets"; - - static int changeEventNum = 0; - static int baseMemberNum = 0; - static int changeLogNum = 0; - static int trackedResourceSetNum = 0; - static int baseNum = 0; - - static TrackedResourceSet trs; - static ChangeLog cl_p1; - static ChangeLog cl_p2; - static Creation creation; - static Deletion deletion; - static Modification modif; - static Base b_p1; - static Base b_p2; - static TrsProviderHandler trsProvider; + private static String uriPrefix = "https://host"; + + private static String ceUriPrefix = uriPrefix + "/changeEvents"; + private static String bUriPrefix = uriPrefix + "/bases"; + + private static String clUriPrefix = uriPrefix + "/changeLogs"; + private static String trsUriPrefix = uriPrefix + "/trackedResourceSets"; + + private static int changeEventNum = 0; + private static int baseMemberNum = 0; + private static int changeLogNum = 0; + private static int trackedResourceSetNum = 0; + private static int baseNum = 0; + + private static TrackedResourceSet trs; + private static ChangeLog cl_p1; + private static ChangeLog cl_p2; + private static Creation creation; + private static Deletion deletion; + private static Modification modif; + private static Base b_p1; + private static Base b_p2; + private static TrsProviderHandler trsProvider; }