Commit e90b4984 authored by Tony Schaller's avatar Tony Schaller

Code refactorings during 3. QA for XUA contribution and get rid of warnings in the whole project

git-svn-id: https://svn.code.sf.net/p/ehealthconnector/code/trunk@1690 e99adb7c-5e35-42fd-8d1b-cdb378af05e8
parent 32a1a97b
......@@ -125,6 +125,7 @@ public class DemoDocCommon {
if ((new OpenSaml2SerializerImpl()).getLoadedMarshallerCount() < 612) {
// This is to load the OpenSaml marshallers that are required
// for de-/serialization
@SuppressWarnings("unused")
ConvenienceUserAccessAuthenticationChImpl dummy = new ConvenienceUserAccessAuthenticationChImpl();
}
outStr = dateFormat.format(new Date())
......
......@@ -259,8 +259,6 @@ public class CdaChV2StructuredBody<EClinicalDocument extends ClinicalDocument>
setId = newDocId;
Integer version = getVersion();
if (version == null)
version = 1;
setId(newDocId);
setVersion(setId, version + 1);
......@@ -279,8 +277,6 @@ public class CdaChV2StructuredBody<EClinicalDocument extends ClinicalDocument>
setId = newDocId;
Integer version = getVersion();
if (version == null)
version = 1;
setId(newDocId);
setVersion(setId, version + 1);
......
......@@ -105,7 +105,7 @@ public class ObservationChTextBuilder extends TextBuilder {
private Comparator<AbstractOrganizer> organizerComparator = new AbstractOrganizerComparator();
private Comparator<AbstractObservation> observationComparator = new AbstractObservationComparator();
private Map<String, Integer> participationsMap = new HashMap();
private Map<String, Integer> participationsMap = new HashMap<String, Integer>();
private final String posCodeSystemOid;
......
......@@ -56,7 +56,8 @@ public enum SerologieForVacd {
/**
* <div class="de">FSME </div> <div class="fr"> Encéphalite à tiques</div>
*/
EUROPEAN_TICK_BORNE_ENCEPHALITIS_VIRUS_AB("26061-2", "European tick borne encephalitis virus Ab"),
EUROPEAN_TICK_BORNE_ENCEPHALITIS_VIRUS_AB("26061-2",
"European tick borne encephalitis virus Ab"),
/**
* <div class="de"> Gelbfieber</div> <div class="fr"> Fièvre jaune</div>
*/
......@@ -212,6 +213,7 @@ public enum SerologieForVacd {
* <div class="de"> enum str</div>
* @return true, if is enum of value set
*/
@SuppressWarnings("unlikely-arg-type")
public boolean isEnumOfValueSet(String enumStr) {
return Arrays.asList(values()).contains(enumStr);
}
......
......@@ -17,14 +17,11 @@
*/
package org.ehealth_connector.cda;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.ehealth_connector.cda.enums.ProblemConcernStatusCode;
import org.ehealth_connector.cda.utils.CdaUtil;
import org.ehealth_connector.common.Identificator;
import org.openhealthtools.mdht.uml.cda.ihe.AllergyIntolerance;
import org.openhealthtools.mdht.uml.cda.ihe.AllergyIntoleranceConcern;
import org.openhealthtools.mdht.uml.hl7.datatypes.II;
......
......@@ -280,8 +280,6 @@ public class DataEnterer {
public List<Identificator> getAssignedEntityIds() {
org.openhealthtools.mdht.uml.cda.AssignedEntity asEntity = mDataEnterer.getAssignedEntity();
org.openhealthtools.mdht.uml.cda.Person person = mDataEnterer.getAssignedEntity()
.getAssignedPerson();
ArrayList<Identificator> retVal = new ArrayList<Identificator>();
if (asEntity.getIds() != null) {
for (II id : asEntity.getIds()) {
......@@ -613,16 +611,6 @@ public class DataEnterer {
}
}
/**
* Method to set
*
* @param person
* the person to set
*/
public void setPerson(org.openhealthtools.mdht.uml.cda.Person person) {
person = person;
}
/**
* Sets the DataEnterer speciality code. This element specifies the
* speciality ("Fachrichtung", e.g. Code "50001" for "Fachärztin/Facharzt
......
......@@ -18,7 +18,6 @@
package org.ehealth_connector.cda.ihe.lab;
import org.ehealth_connector.cda.MdhtEntryFacade;
import org.ehealth_connector.common.Identificator;
import org.openhealthtools.mdht.uml.cda.ihe.lab.LABFactory;
/**
......@@ -32,9 +31,6 @@ public abstract class AbstractLaboratoryReportDataProcessingEntry extends
*/
public AbstractLaboratoryReportDataProcessingEntry() {
super(LABFactory.eINSTANCE.createLaboratoryReportDataProcessingEntry().init());
// if (getMdht().getAct() != null)
// getMdht().getAct().getTemplateIds()
// .add(new Identificator("2.16.756.5.30.1.1.10.4.4").getIi());
}
/**
......@@ -46,9 +42,6 @@ public abstract class AbstractLaboratoryReportDataProcessingEntry extends
public AbstractLaboratoryReportDataProcessingEntry(
org.openhealthtools.mdht.uml.cda.ihe.lab.LaboratoryReportDataProcessingEntry mdht) {
super(mdht);
// if (getMdht().getAct() != null)
// getMdht().getAct().getTemplateIds()
// .add(new Identificator("2.16.756.5.30.1.1.10.4.4").getIi());
}
/**
......@@ -60,9 +53,6 @@ public abstract class AbstractLaboratoryReportDataProcessingEntry extends
public AbstractLaboratoryReportDataProcessingEntry(SpecimenAct act) {
this();
setSpecimenAct(act);
// if (getMdht().getAct() != null)
// getMdht().getAct().getTemplateIds()
// .add(new Identificator("2.16.756.5.30.1.1.10.4.4").getIi());
}
/**
......
......@@ -175,6 +175,7 @@ public class TestUtils {
return true;
}
@SuppressWarnings("unlikely-arg-type")
public static boolean isEqual(Telecoms t1, Telecoms t2) {
if (t1.getEMails() != null) {
for (int i = 0; i < t1.getEMails().size(); i++) {
......
......@@ -169,6 +169,7 @@ public abstract class AbstractTestHelper {
return true;
}
@SuppressWarnings("unlikely-arg-type")
public static boolean isEqual(Telecoms t1, Telecoms t2) {
if (t1.getEMails() != null) {
for (int i = 0; i < t1.getEMails().size(); i++) {
......
......@@ -61,7 +61,8 @@ import org.xml.sax.SAXException;
*/
public class SimplePpqClient extends AbstractSoapClient<Response> implements PpqClient {
private static final String EHS_2015_POLYADMIN = "urn:e-health-suisse:2015:policy-administration:";
// private static final String EHS_2015_POLYADMIN =
// "urn:e-health-suisse:2015:policy-administration:";
public SimplePpqClient(PpClientConfig clientConfiguration) {
setLogger(LoggerFactory.getLogger(getClass()));
......
......@@ -31,15 +31,6 @@ import org.opensaml.core.xml.io.Unmarshaller;
import org.opensaml.core.xml.io.UnmarshallerFactory;
import org.w3c.dom.Element;
/**
* <!-- @formatter:off -->
* <div class="en">HEREISENGLISH</div>
* <div class="de">HIERISTDEUTSCH</div>
* <div class="fr"></div>
* <div class="it"></div>
*
* <!-- @formatter:on -->
*/
public class UpdatePolicyRequestImplTest extends InitializerTestHelper {
private Assertion testAssertion;
......
......@@ -60,21 +60,6 @@ public class PrivacyPolicyFeedDeserialiserTest extends InitializerTestHelper {
private Element getAssertionAsElement(byte[] xmlByteArray) throws DeserializeException {
try {
// final JAXBContext jaxbContext =
// JAXBContext.newInstance("suisse.health.e._2015.policy_administration");
// final Unmarshaller unmarshaller =
// jaxbContext.createUnmarshaller();
// final JAXBElement<?> jxbAssBasReqTyp = (JAXBElement<?>)
// unmarshaller
// .unmarshal(new ByteArrayInputStream(xmlByteArray));
//
// final AssertionBasedRequest wsAssBasReqTyp =
// (AssertionBasedRequest) jxbAssBasReqTyp.getValue();
//
// final Assertion wsAssertion = wsAssBasReqTyp.getAssertion();
//
// final Marshaller marshaller = jaxbContext.createMarshaller();
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
final Document doc = dbf.newDocumentBuilder().newDocument();
// marshaller.marshal(wsAssertion, doc);
......
......@@ -30,18 +30,20 @@ public class SoapException extends ClientSendException {
private static final long serialVersionUID = 718920336633885906L;
/** the soap exception code */
@SuppressWarnings("unused")
private String code;
/** the soap exception message */
@SuppressWarnings("unused")
private String message;
/**
*
*
* <!-- @formatter:off -->
* <div class="en">Default constructor to instanciate the object.</div>
* <div class="de">Default Konstruktor für die instanziierung des objects.</div>
* <div class="fr">VOICIFRANCAIS</div>
* <div class="it">ITALIANO</div>
*
* <div class="fr"></div>
* <div class="it"></div>
*
* @param aCode
* <div class="en">The code of the exception.</div>
* <div class="de">Der Code des Fehlers.</div>
......
......@@ -274,14 +274,6 @@ public abstract class AbstractSoapClient<T> {
final Node bodyNode = getNode(soapDocument.getDocumentElement(),
"/" + prefix + "Envelope/" + prefix + "Body");
// final Node first = soapDocument.getFirstChild();
// System.out.println("First: " + first.getNodeName());
// final Node lastOfFirst = first.getLastChild();
// System.out.println("LastOfFirst: " + lastOfFirst.getNodeName());
// // get the xml response node
// final Node responseNode = lastOfFirst.getFirstChild();
// System.out.println("responseNode: " + responseNode.getNodeName());
NodeList reponseNodes = ((Element) bodyNode).getElementsByTagNameNS("*", localName);
if ((reponseNodes == null) || (reponseNodes.getLength() < 1)) {
reponseNodes = ((Element) bodyNode).getElementsByTagNameNS(nameSpaceUri, localName);
......@@ -335,10 +327,6 @@ public abstract class AbstractSoapClient<T> {
retVal = content;
} else {
// final String pattern = "--" + boundary +
// "\\R(.*?\\R*?)*?\\R--" + boundary + "--";
// final String pattern = "<soap\\:Envelope
// (.*?\\R*?)*?\\R</soap\\:Envelope>";
final String pattern = "<([a-zA-Z:]+)Envelope(.+)>(.+)</([a-zA-Z:]+)Envelope>";
final Pattern regex = Pattern.compile(pattern);
final Matcher matcher = regex.matcher(content);
......
......@@ -51,9 +51,6 @@ public class ClientFactory {
}
public static XuaClient getXuaClient(XuaClientConfig clientConfiguration) {
// if (clientConfiguration.isSimple()) {
return new SimpleXuaClient(clientConfiguration);
// }
// return new JaxwsXuaClient(clientConfiguration);
}
}
......@@ -89,7 +89,7 @@ public class IdpClientByBrowserAndProtocolHandler implements IdpClient {
}
/**
*
*
* <!-- @formatter:off -->
* <div class="en">Method to read content from a file packed in a jar file.</div>
* <div class="de">Methode um den Inhalt eines Files gepacket in einem jar File zu laden.</div>
......@@ -129,7 +129,7 @@ public class IdpClientByBrowserAndProtocolHandler implements IdpClient {
}
/**
*
*
* {@inheritDoc}
*
* @see org.ehealth_connector.security.communication.clients.IdpClient#send(org.ehealth_connector.security.authentication.AuthnRequest)
......@@ -188,7 +188,9 @@ public class IdpClientByBrowserAndProtocolHandler implements IdpClient {
if (tempFile.exists()) {
tempFile.delete();
}
if ((line == null) && (!line.startsWith(config.getProtocolHandlerName()))) {
if (line == null) {
// maybe add this restriction, later:
// (!line.startsWith(config.getProtocolHandlerName()))
throw new ClientSendException("No SAML response found");
}
line = java.net.URLDecoder.decode(line, "UTF-8");
......
......@@ -49,8 +49,6 @@ import org.ehealth_connector.security.exceptions.DeserializeException;
import org.ehealth_connector.security.exceptions.SerializeException;
import org.ehealth_connector.security.saml2.Response;
import org.ehealth_connector.security.serialization.impl.AuthnRequestSerializerImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
......@@ -68,8 +66,6 @@ public class IdpSoapBindingClientByBasicAuth extends AbstractIdpClient {
private IdpClientBasicAuthConfigImpl config;
private Logger logger = LoggerFactory.getLogger(getClass());
public IdpSoapBindingClientByBasicAuth(IdpClientBasicAuthConfigImpl clientConfiguration) {
config = clientConfiguration;
......@@ -194,16 +190,6 @@ public class IdpSoapBindingClientByBasicAuth extends AbstractIdpClient {
@Override
Response parseResponse(CloseableHttpResponse response) throws ClientSendException {
try {
// // build new document
// final Properties systemProperties = System.getProperties();
// logger.debug("the document builder factory: "
// +
// systemProperties.get("javax.xml.parsers.DocumentBuilderFactory"));
// systemProperties.remove("javax.xml.parsers.DocumentBuilderFactory");
// systemProperties.setProperty("javax.xml.parsers.DocumentBuilderFactory",
// "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
//
// System.setProperties(systemProperties);
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
......
......@@ -60,8 +60,10 @@ public class SignCryptModuleImpl implements SignCryptModule {
private String keyStorePassword;
@SuppressWarnings("unused")
private KeyStore trustStore;
@SuppressWarnings("unused")
private String trustStorePassword;
/**
......
......@@ -26,15 +26,15 @@ import org.w3c.dom.Element;
/**
* <!-- @formatter:off -->
* <div class="en">HEREISENGLISH</div>
* <div class="de">HIERISTDEUTSCH</div>
* <div class="en">Base Serializer for OpenSaml objects.</div>
* <div class="de">Basis Serializer für OpenSaml-Objekte.</div>
* <div class="fr"></div>
* <div class="it"></div>
*
* <!-- @formatter:on -->
*/
public class BaseSerializerImpl extends AbstractSerializerImpl implements Serializer<Base> {
@SuppressWarnings("unchecked")
@Override
public byte[] toXmlByteArray(Base aSecurityObject) throws SerializeException {
try {
......@@ -45,6 +45,7 @@ public class BaseSerializerImpl extends AbstractSerializerImpl implements Serial
}
}
@SuppressWarnings("unchecked")
@Override
public Element toXmlElement(Base aSecurityObject) throws SerializeException {
try {
......@@ -55,6 +56,7 @@ public class BaseSerializerImpl extends AbstractSerializerImpl implements Serial
}
}
@SuppressWarnings("unchecked")
@Override
public String toXmlString(Base aSecurityObject) throws SerializeException {
try {
......
......@@ -20,8 +20,6 @@ package org.ehealth_connector.security.communication.clients.impl;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.security.KeyStore;
import org.ehealth_connector.security.communication.clients.IdpClient;
import org.ehealth_connector.security.communication.clients.XuaClient;
import org.ehealth_connector.security.communication.config.XuaClientConfig;
......@@ -48,17 +46,9 @@ import org.junit.Test;
public class ClientFactoryTest {
private IdpClientViaHttpProxyConfigImpl testClientConfigurationHttpProxy;
private String testProxyHost;
private int testProxyPort;
private String testProxyProtocol;
private IdpClientCertificateAuthConfigImpl testClientConfigurationAuthConfig;
private String testStorePassword;
private KeyStore testKeyStore;
private IdpClientBasicAuthConfigImpl testClientBasicAuthConfig;
private String testBasicAuthPassword;
private String testBasicAuthUsername;
private XuaClientConfig testClientConfigurationXua;
public IdpClientByBrowserAndProtocolHandlerConfigImpl testIdpClientByBrowserAndProtocolHandlerConfig;
......@@ -86,10 +76,10 @@ public class ClientFactoryTest {
* {@link org.ehealth_connector.security.communication.clients.impl.ClientFactory#getIdpClient(org.ehealth_connector.security.communication.config.IdpClientConfig)}.
*/
@Test
public void testGetIdpClientHttpProxy() {
final IdpClient client = ClientFactory.getIdpClient(testClientConfigurationHttpProxy);
public void testGetIdpClientBasicAuth() {
final IdpClient client = ClientFactory.getIdpClient(testClientBasicAuthConfig);
assertNotNull(client);
assertTrue(client instanceof IdpClientByProxy);
assertTrue(client instanceof IdpSoapBindingClientByBasicAuth);
}
/**
......@@ -108,33 +98,33 @@ public class ClientFactoryTest {
* {@link org.ehealth_connector.security.communication.clients.impl.ClientFactory#getIdpClient(org.ehealth_connector.security.communication.config.IdpClientConfig)}.
*/
@Test
public void testGetIdpClientBasicAuth() {
final IdpClient client = ClientFactory.getIdpClient(testClientBasicAuthConfig);
public void testGetIdpClientHttpProxy() {
final IdpClient client = ClientFactory.getIdpClient(testClientConfigurationHttpProxy);
assertNotNull(client);
assertTrue(client instanceof IdpSoapBindingClientByBasicAuth);
assertTrue(client instanceof IdpClientByProxy);
}
/**
* Test method for
* {@link org.ehealth_connector.security.communication.clients.impl.ClientFactory#getIdpClient(org.ehealth_connector.security.communication.config.IdpClientConfig)}.
* {@link org.ehealth_connector.security.communication.clients.impl.ClientFactory#getXuaClient(org.ehealth_connector.security.communication.config.XuaClientConfig)}.
*/
@Test
public void testIdpClientByBrowserAndProtocolHandlerConfig() {
final IdpClient client = ClientFactory
.getIdpClient(testIdpClientByBrowserAndProtocolHandlerConfig);
public void testGetXuaClient() {
final XuaClient client = ClientFactory.getXuaClient(testClientConfigurationXua);
assertNotNull(client);
assertTrue(client instanceof IdpClientByBrowserAndProtocolHandler);
assertTrue(client instanceof SimpleXuaClient);
}
/**
* Test method for
* {@link org.ehealth_connector.security.communication.clients.impl.ClientFactory#getXuaClient(org.ehealth_connector.security.communication.config.XuaClientConfig)}.
* {@link org.ehealth_connector.security.communication.clients.impl.ClientFactory#getIdpClient(org.ehealth_connector.security.communication.config.IdpClientConfig)}.
*/
@Test
public void testGetXuaClient() {
final XuaClient client = ClientFactory.getXuaClient(testClientConfigurationXua);
public void testIdpClientByBrowserAndProtocolHandlerConfig() {
final IdpClient client = ClientFactory
.getIdpClient(testIdpClientByBrowserAndProtocolHandlerConfig);
assertNotNull(client);
assertTrue(client instanceof SimpleXuaClient);
assertTrue(client instanceof IdpClientByBrowserAndProtocolHandler);
}
}
......@@ -45,15 +45,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
/**
* <!-- @formatter:off -->
* <div class="en">HEREISENGLISH</div>
* <div class="de">HIERISTDEUTSCH</div>
* <div class="fr">VOICIFRANCAIS</div>
* <div class="it">ITALIANO</div>
*
* <!-- @formatter:on -->
*/
public class IdpClientByBrowserAndProtocolHandlerTest extends ServerTestHelper {
private static Logger logger = LoggerFactory
......@@ -61,16 +52,9 @@ public class IdpClientByBrowserAndProtocolHandlerTest extends ServerTestHelper {
private static HttpServer server;
@SuppressWarnings("unused")
private static int httpPort;
private IdpClientByBrowserAndProtocolHandler client;
private String testFilename;
private AuthnRequest testAuthnRequest;
private Response testResponse;
@BeforeClass
public static void setUpBefore() throws IOException {
final SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(15000)
......@@ -98,6 +82,12 @@ public class IdpClientByBrowserAndProtocolHandlerTest extends ServerTestHelper {
server.stop();
}
private IdpClientByBrowserAndProtocolHandler client;
private String testFilename;
private AuthnRequest testAuthnRequest;
/**
* set up test parameters
*/
......@@ -116,7 +106,7 @@ public class IdpClientByBrowserAndProtocolHandlerTest extends ServerTestHelper {
/**
* Test method for
* {@link org.ehealth_connector.security.communication.clients.impl.IdpClientByBrowserAndProtocolHandler#readFromJARFile(java.lang.String)}.
*
*
* @throws IOException
*/
@Test
......@@ -129,7 +119,7 @@ public class IdpClientByBrowserAndProtocolHandlerTest extends ServerTestHelper {
/**
* Test method for
* {@link org.ehealth_connector.security.communication.clients.impl.IdpClientByBrowserAndProtocolHandler#send(org.ehealth_connector.security.authentication.AuthnRequest)}.
*
*
* @throws ClientSendException
*/
@Test
......
......@@ -23,15 +23,6 @@ import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
/**
* <!-- @formatter:off -->
* <div class="en">HEREISENGLISH</div>
* <div class="de">HIERISTDEUTSCH</div>
* <div class="fr">VOICIFRANCAIS</div>
* <div class="it">ITALIANO</div>
*
* <!-- @formatter:on -->
*/
public class IdpClientByBrowserAndProtocolHandlerConfigBuilderImplTest {
private IdpClientByBrowserAndProtocolHandlerConfigBuilderImpl builder;
......@@ -39,14 +30,10 @@ public class IdpClientByBrowserAndProtocolHandlerConfigBuilderImplTest {
private String testUrl;
/**
* <!-- @formatter:off -->
* <div class="en">HEREISENGLISH</div>
* <div class="de">HIERISTDEUTSCH</div>
* <div class="fr">VOICIFRANCAIS</div>
* <div class="it">ITALIANO</div>
* Initialization of the test.
*
* @throws java.lang.Exception
* <!-- @formatter:on -->
* @throws Exception
* the exception
*/
@Before
public void setUp() throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment