Skip to content

Commit

Permalink
Merge branch 'aiccra-tip-integration' into aiccra-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Feb 19, 2024
2 parents f17909b + f1f2281 commit 839005f
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class TipParameters extends MarloBaseEntity implements java.io.Serializab
@Expose
private String privateKey;
@Expose
private String tipBaseUrl;
@Expose
private Date tokenDueDate;

@Override
Expand All @@ -61,6 +63,10 @@ public String getPrivateKey() {
return privateKey;
}

public String getTipBaseUrl() {
return tipBaseUrl;
}

public String getTipLoginService() {
return tipLoginService;
}
Expand Down Expand Up @@ -96,10 +102,15 @@ public void setPrivateKey(String privateKey) {
this.privateKey = privateKey;
}

public void setTipBaseUrl(String tipBaseUrl) {
this.tipBaseUrl = tipBaseUrl;
}

public void setTipLoginService(String tipLoginService) {
this.tipLoginService = tipLoginService;
}


public void setTipStatusService(String tipStatusService) {
this.tipStatusService = tipStatusService;
}
Expand Down
3 changes: 3 additions & 0 deletions marlo-data/src/main/resources/xmls/TipParameters.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
<property name="privateKey" type="string">
<column name="private_key" />
</property>
<property name="tipBaseUrl" type="string">
<column name="tip_base_url"/>
</property>
</class>
</hibernate-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,36 @@ public TipDinamicUrlGenerationAction() {

public String createDinamicURL() {
String tipURL = null;
try {
List<TipParameters> tipParameters = tipParametersManager.findAll();
boolean isCGIARUser = true;

try {
String userEmail = "", token = "", loginService = "";
if (this.getCurrentUser() != null && this.getCurrentUser().getEmail() != null) {
userEmail = this.getCurrentUser().getEmail();
if (this.getCurrentUser().isCgiarUser() == true) {
isCGIARUser = true;
} else {
isCGIARUser = false;
}
}
if (tipParameters != null && !tipParameters.isEmpty() && tipParameters.get(0) != null) {
if (tipParameters.get(0).getTipTokenService() != null) {
token = tipParameters.get(0).getTokenValue();

List<TipParameters> tipParameters = tipParametersManager.findAll();
if (isCGIARUser) {
if (tipParameters != null && !tipParameters.isEmpty() && tipParameters.get(0) != null) {
if (tipParameters.get(0).getTipTokenService() != null) {
token = tipParameters.get(0).getTokenValue();
}
if (tipParameters.get(0).getTipLoginService() != null) {
loginService = tipParameters.get(0).getTipLoginService();
}
}
if (tipParameters.get(0).getTipLoginService() != null) {
loginService = tipParameters.get(0).getTipLoginService();
tipURL = loginService + "/" + token + "/staff/" + userEmail;
} else {
// Not CGIAR User
if (tipParameters != null && tipParameters.get(0) != null && tipParameters.get(0).getTipBaseUrl() != null) {
tipURL = tipParameters.get(0).getTipBaseUrl();
}
}
tipURL = loginService + "/" + token + "/staff/" + userEmail;
} catch (NumberFormatException e) {
LOG.error("Error getting tip URL: " + e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public String save() {
if (tipParameter.getId() != null) {
tipParameterSave.setId(tipParameter.getId());
}
if (tipParameter.getTipBaseUrl() != null) {
tipParameterSave.setTipBaseUrl(tipParameter.getTipBaseUrl());
}
if (tipParameter.getTipLoginService() != null) {
tipParameterSave.setTipLoginService(tipParameter.getTipLoginService());
}
Expand Down
1 change: 1 addition & 0 deletions marlo-web/src/main/resources/custom/aicrra.properties
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ tipParameterManagement.title=TIP Management
tipParameter.privateKey=Private Key
tipParameter.tipTokenService=Token Service Endpoint
tipParameter.tipLoginService=Login Service Endpoint
tipParameter.tipBaseUrl=Base URL
tipParameter.tipStatusService= Status Service Endpoint
tipParameter.tokenValue= Token Value
tipParameter.updateToken= Update Token
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE tip_parameters ADD tip_base_url text NULL;
1 change: 1 addition & 0 deletions marlo-web/src/main/resources/global.properties
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ tipParameterManagement.title=TIP Management
tipParameter.privateKey=Private Key
tipParameter.tipTokenService=Token Service Endpoint
tipParameter.tipLoginService=Login Service Endpoint
tipParameter.tipBaseUrl=Base URL
tipParameter.tipStatusService= Status Service Endpoint
tipParameter.tokenValue= Token Value
tipParameter.updateToken= Update Token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{"label":"tipManagement", "nameSpace":"", "action":""}
]/]


[#include "/WEB-INF/global/pages/header.ftl" /]
<hr />

Expand All @@ -35,6 +36,9 @@
<h4 class="sectionTitle">[@s.text name="tipParameterManagement.title" /]</h4>

<div id="tipManagement" class="borderBox">
<div class="form-group">
[@customForm.input name="tipParameter.tipBaseUrl" i18nkey="tipParameter.tipBaseUrl" className="description limitWords-100" required=true /]
</div>
<div class="form-group">
[@customForm.input name="tipParameter.privateKey" i18nkey="tipParameter.privateKey" className="description limitWords-100" required=true /]
</div>
Expand Down

0 comments on commit 839005f

Please sign in to comment.