Skip to content

Commit

Permalink
Merge pull request #22 from samply/feature/site
Browse files Browse the repository at this point in the history
Searchbroker api calls
  • Loading branch information
TasDeniz authored Mar 5, 2021
2 parents 1b1c4af + 69e2079 commit 2df180d
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 45 deletions.
26 changes: 17 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,50 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [7.3.0 - 2021-03-04]
### Added
- set site name when registering at the searchbroker
- delete searchbroker registration in the searchbroker database
- feature property to activate or deactivate "set site name" feature
### Changed
- share-common version 4.1.0

## [7.2.4 - 2021-02-25]
## Fixed
### Fixed
- share-common 4.0.1 fix for icinga

## [7.2.3 - 2021-02-12]
## Fixed
### Fixed
- load last inquiry result

## [7.2.2 - 2021-02-10]
## Fixed
### Fixed
- read EncId instead of returning jsonString
- check the headers jsonpaths and target-url before using it

## [7.2.1 - 2021-02-04]
## Added
### Added
- github actions for automatic docker image builds in different configuration (currently samply, c4 and dktk)
- Environment Variables for the configuration file [_cts_info.xml](./src/docker/_cts_info.xml).
- Environment Variables for the new patientlistUrl and projectPseudonymisationUrl. [see this file](./src/docker/samply_common_urls.xml)
## Changed
### Changed
- Removed hard coded urls from [samply_common_urls](./src/docker/samply_common_urls.xml)
- Moved JMX Exporter and start.sh to "/docker" in the container
- Base image of the container from 8.5.32-jre8-alpine to 9-jdk8-openjdk-slim
## Fixed
### Fixed
- send pseudonymised bundle as JSON only
- renamed some methods
- Automatic generation of java classes from xsd files

## [7.2.0 - 2021-02-03]
## Added
### Added
- added process 9b for CTS
- added JSONPath
- encryption/decryption of FHIR references
- read localIds from Mainzelliste

## [7.1.0 - 2021-02-02]
## Added
### Added
- Percentage Logger
- Java Doc
- Integrate projectpseudonymization and patientlist
Expand All @@ -48,7 +56,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Github release
### Changed
- Samply parent 11.1.0
## Added
### Added
- Github Actions
- Google Code Style
### Bugfix
Expand Down
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>share-client</artifactId>
<version>7.2.4-SNAPSHOT</version>
<version>7.3.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>Connector</name>
Expand Down Expand Up @@ -55,7 +55,7 @@
<properties>
<!-- Samply dependencies -->
<version.samply.common.config>5.1.0</version.samply.common.config>
<share-common.version>4.0.1</share-common.version>
<share-common.version>4.1.0</share-common.version>
<share-dto.version>5.0.0</share-dto.version>
<jsf-renderer.version>2.0.0</jsf-renderer.version>
<common-mailing.version>3.0.0</common-mailing.version>
Expand Down Expand Up @@ -107,13 +107,15 @@
<togglz-jsf.version>2.6.1.Final</togglz-jsf.version>
<swagger-ui.version>3.25.0</swagger-ui.version>
<microprofile-openapi-api.version>2.0-MR1</microprofile-openapi-api.version>
<postgresql.version>42.2.0</postgresql.version>
<postgresql.version>42.2.19</postgresql.version>
<commons-validator.version>1.6</commons-validator.version>
<junit.version>4.12</junit.version>
<jsf-api.version>2.2.15</jsf-api.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
<tink.version>1.4.0</tink.version>
<jaxb2-maven-plugin.version>2.5.0</jaxb2-maven-plugin.version>
<json-path.version>2.5.0</json-path.version>
<primefaces.version>8.0</primefaces.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -420,7 +422,12 @@
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.5.0</version>
<version>${json-path.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
</dependencies>

Expand Down
1 change: 1 addition & 0 deletions src/docker/features.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ DKTK_CENTRAL_SEARCH={feature_DKTK_CENTRAL_SEARCH}
BBMRI_DIRECTORY_SYNC={feature_BBMRI_DIRECTORY_SYNC}
NNGM_CTS={feature_NNGM_CTS}
NNGM_ENCRYPT_ID={feature_NNGM_ENCRYPT_ID}
SET_SITE_NAME ={feature_SET_SITE_NAME}
1 change: 1 addition & 0 deletions src/docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ sed -i "s/{feature_BBMRI_DIRECTORY_SYNC}/${feature_BBMRI_DIRECTORY_SYNC:-false}/
sed -i "s/{feature_DKTK_CENTRAL_SEARCH}/${feature_DKTK_CENTRAL_SEARCH:-false}/" "$file"
sed -i "s/{feature_NNGM_CTS}/${feature_NNGM_CTS:-false}/" "$file"
sed -i "s|{feature_NNGM_ENCRYPT_ID}|${feature_NNGM_ENCRYPT_ID:-false}|" "$file"
sed -i "s|{feature_SET_SITE_NAME}|${feature_SET_SITE_NAME:-false}|" "$file"

file=${CATALINA_HOME}/conf/${PROJECT}_cts_info.xml
sed -i "s|{nngm-magicpl-apikey}|${NNGM_MAGICPL_APIKEY}|" "$file"
Expand Down
101 changes: 99 additions & 2 deletions src/main/java/de/samply/share/client/control/BrokerBean.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package de.samply.share.client.control;

import static de.samply.share.client.model.db.enums.BrokerStatusType.BS_ACTIVATION_OK;
import static de.samply.share.client.model.db.enums.BrokerStatusType.BS_OK;

import de.samply.share.client.feature.ClientFeature;
import de.samply.share.client.model.db.enums.AuthSchemeType;
import de.samply.share.client.model.db.enums.BrokerStatusType;
import de.samply.share.client.model.db.enums.ReplyRuleType;
Expand All @@ -15,6 +17,8 @@
import de.samply.share.client.util.db.CredentialsUtil;
import de.samply.share.client.util.db.InquiryHandlingRuleUtil;
import java.io.Serializable;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
Expand Down Expand Up @@ -43,6 +47,10 @@ public class BrokerBean implements Serializable {

private ReplyRuleType newBrokerReplyRule;

private String newBrokerSite;

private List<String> availableBrokerSites;

public List<Broker> getBrokerList() {
return brokerList;
}
Expand Down Expand Up @@ -83,6 +91,22 @@ public void setNewBrokerReplyRule(ReplyRuleType newBrokerReplyRule) {
this.newBrokerReplyRule = newBrokerReplyRule;
}

public String getNewBrokerSite() {
return newBrokerSite;
}

public void setNewBrokerSite(String newBrokerSite) {
this.newBrokerSite = newBrokerSite;
}

public List<String> getAvailableBrokerSites() {
return availableBrokerSites;
}

public void setAvailableBrokerSites(List<String> availableBrokerSites) {
this.availableBrokerSites = availableBrokerSites;
}

/**
* Initialize the broker list.
*/
Expand All @@ -93,12 +117,38 @@ public void init() {
newBrokerEmail = "";
newBrokerFullResult = false;
newBrokerReplyRule = ReplyRuleType.RR_NO_AUTOMATIC_ACTION;
newBrokerSite = "";
}

public Credentials getCredentials(Broker broker) {
return CredentialsUtil.getCredentialsForBroker(broker);
}

/**
* Get the site names from the searchbroker.
*
* @param broker the searchbroker
*/
public void getSiteNames(Broker broker) {
try {
BrokerConnector brokerConnector = new BrokerConnector(broker);
availableBrokerSites = brokerConnector.getSiteNames();
checkDefaultSite();
} catch (URISyntaxException | BrokerConnectorException e) {
logger.error("Caught BrokerConnectorException when trying to register to broker", e);
}
}

private void checkDefaultSite() {
String site = ApplicationBean.getBridgeheadInfos().getName();
if (site != null) {
List<String> match = checkSiteName(site);
if (match.size() > 0) {
newBrokerSite = match.get(0);
}
}
}

private void refreshBrokerList() {
brokerList = BrokerUtil.fetchBrokers();
}
Expand All @@ -120,7 +170,11 @@ public String sendActivationCode(Broker broker, String activationCode) {
.error().add();
return "";
} else {
broker.setStatus(BS_OK);
if (ClientFeature.SET_SITE_NAME.isActive()) {
broker.setStatus(BS_ACTIVATION_OK);
} else {
broker.setStatus(BS_OK);
}
BrokerUtil.updateBroker(broker);
return "broker_list?faces-redirect=true";
}
Expand Down Expand Up @@ -184,7 +238,6 @@ public String join() {
BrokerStatusType brokerStatus = brokerConnector.register();
newBroker.setStatus(brokerStatus);
BrokerUtil.updateBroker(newBroker);

// Insert a new default handling rule for this broker
InquiryHandlingRule inquiryHandlingRule = new InquiryHandlingRule();
inquiryHandlingRule.setBrokerId(brokerId);
Expand All @@ -199,4 +252,48 @@ public String join() {
// TODO faces message on error and success?
return "broker_list?faces-redirect=true";
}

/**
* Send an activation code to the broker in order to complete registration.
*
* @param broker the broker to send the code to
* @param siteName the code to send to the broker
* @return navigation outcome
*/
public String sendSiteName(Broker broker, String siteName) {
try {
BrokerConnector brokerConnector = new BrokerConnector(broker);
int retCode = brokerConnector.sendSiteName(siteName);
if (retCode != HttpStatus.SC_OK) {
Messages.create("bl.sendSiteNameError")
.detail(Integer.toString(retCode))
.error().add();
return "";
} else {
broker.setStatus(BS_OK);
BrokerUtil.updateBroker(broker);
return "broker_list?faces-redirect=true";
}
} catch (BrokerConnectorException e) {
logger.error("Caught BrokerConnectorException when trying to send site name to broker", e);
return "";
}
}

/**
* Check if the entered value is inside the available site name list.
*
* @param enteredValue value which the user is searching
* @return the site names which matches with the entered value from the user
*/
public List<String> checkSiteName(String enteredValue) {
List<String> matches = new ArrayList<>();
for (String s : availableBrokerSites) {
if (s.toLowerCase().startsWith(enteredValue.toLowerCase())) {
matches.add(s);
}
}
return matches;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public enum ClientFeature implements Feature {
NNGM_CTS,

@Label("NNGM ENCRYPT_ID")
NNGM_ENCRYPT_ID;
NNGM_ENCRYPT_ID,

@Label("Set Site Name")
SET_SITE_NAME;

public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import de.samply.share.client.job.util.InquiryCriteriaEntityType;
import de.samply.share.client.job.util.InquiryCriteriaFactory;
import de.samply.share.client.model.EnumInquiryPresent;
import de.samply.share.client.model.db.enums.BrokerStatusType;
import de.samply.share.client.model.db.enums.EntityType;
import de.samply.share.client.model.db.enums.EventMessageType;
import de.samply.share.client.model.db.enums.InquiryCriteriaStatusType;
Expand Down Expand Up @@ -67,6 +68,9 @@ public void execute(JobExecutionContext jobExecutionContext) {
if (credentials == null || SamplyShareUtils.isNullOrEmpty(credentials.getPasscode())) {
logger.warn("Credentials missing for broker id " + broker.getId());
continue;
} else if (broker.getStatus().equals(BrokerStatusType.BS_ACTIVATION_OK)) {
logger.warn("Site name missing for broker " + broker.getId());
break;
}
try {
Map<String, String> inquiries = brokerConnector.getInquiryList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,14 @@ bl_emailRequiredMsg=Bitte Email Adresse eingeben
bl_joinBtn=Beitreten
bl_requestFullResultsTooltip=Wenn aktiviert, werden direkt nach der Anfrage, die Ergebnisdatens\u00E4tze vom lokalen Datenmanagement berechnet. Die kann mitunter viel Zeit in Anspruch nehmen. Daher kann es hilfreich sein, dies zu deaktivieren. Bei \u00E4lteren Versionen der REST-Schnittstelle kann unter Umst\u00E4nden die Option nicht deaktiviert werden,
bl_requestFullResults=Erg. anfordern
bl_newSite=Standortnamen
bl_sendNewSite=Standortnamen senden
# BrokerStatusType
BS_UNREACHABLE=Unerreichbar
BS_USER_UNKNOWN=Unbekannter Nutzer
BS_AUTHENTICATION_ERROR=Anmeldung fehlgeschlagen
BS_ACTIVATION_PENDING=Aktivierung steht aus
BS_ACTIVATION_OK=Aktivierung erfolgreich
BS_OK=OK
# userList.xhtml
ul_title=Benutzerverwaltung
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,14 @@ bl_emailRequiredMsg=Please enter your email address
bl_joinBtn=Join
bl_requestFullResultsTooltip=When activated, local datamanagement will write all result datasets to the disk. This might be unwanted in some scenarios and can take a while. However, some older versions of the REST api of the local datamanagement might not support turning this off.
bl_requestFullResults=Request Result
bl_newSite=Site name
bl_sendNewSite=Send site name
# BrokerStatusType
BS_UNREACHABLE=Unreachable
BS_USER_UNKNOWN=Unknown user
BS_AUTHENTICATION_ERROR=Authentication error
BS_ACTIVATION_PENDING=Activation pending
BS_ACTIVATION_OK=Activation successful
BS_OK=OK
# userList.xhtml
ul_title=User management
Expand Down
Loading

0 comments on commit 2df180d

Please sign in to comment.