Skip to content

Commit 839005f

Browse files
committed
Merge branch 'aiccra-tip-integration' into aiccra-dev
2 parents f17909b + f1f2281 commit 839005f

File tree

8 files changed

+46
-8
lines changed

8 files changed

+46
-8
lines changed

marlo-data/src/main/java/org/cgiar/ccafs/marlo/data/model/TipParameters.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class TipParameters extends MarloBaseEntity implements java.io.Serializab
3737
@Expose
3838
private String privateKey;
3939
@Expose
40+
private String tipBaseUrl;
41+
@Expose
4042
private Date tokenDueDate;
4143

4244
@Override
@@ -61,6 +63,10 @@ public String getPrivateKey() {
6163
return privateKey;
6264
}
6365

66+
public String getTipBaseUrl() {
67+
return tipBaseUrl;
68+
}
69+
6470
public String getTipLoginService() {
6571
return tipLoginService;
6672
}
@@ -96,10 +102,15 @@ public void setPrivateKey(String privateKey) {
96102
this.privateKey = privateKey;
97103
}
98104

105+
public void setTipBaseUrl(String tipBaseUrl) {
106+
this.tipBaseUrl = tipBaseUrl;
107+
}
108+
99109
public void setTipLoginService(String tipLoginService) {
100110
this.tipLoginService = tipLoginService;
101111
}
102112

113+
103114
public void setTipStatusService(String tipStatusService) {
104115
this.tipStatusService = tipStatusService;
105116
}

marlo-data/src/main/resources/xmls/TipParameters.hbm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
<property name="privateKey" type="string">
2727
<column name="private_key" />
2828
</property>
29+
<property name="tipBaseUrl" type="string">
30+
<column name="tip_base_url"/>
31+
</property>
2932
</class>
3033
</hibernate-mapping>

marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/json/tip/TipDinamicUrlGenerationAction.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,36 @@ public TipDinamicUrlGenerationAction() {
4444

4545
public String createDinamicURL() {
4646
String tipURL = null;
47-
try {
48-
List<TipParameters> tipParameters = tipParametersManager.findAll();
47+
boolean isCGIARUser = true;
4948

49+
try {
5050
String userEmail = "", token = "", loginService = "";
5151
if (this.getCurrentUser() != null && this.getCurrentUser().getEmail() != null) {
5252
userEmail = this.getCurrentUser().getEmail();
53+
if (this.getCurrentUser().isCgiarUser() == true) {
54+
isCGIARUser = true;
55+
} else {
56+
isCGIARUser = false;
57+
}
5358
}
54-
if (tipParameters != null && !tipParameters.isEmpty() && tipParameters.get(0) != null) {
55-
if (tipParameters.get(0).getTipTokenService() != null) {
56-
token = tipParameters.get(0).getTokenValue();
59+
60+
List<TipParameters> tipParameters = tipParametersManager.findAll();
61+
if (isCGIARUser) {
62+
if (tipParameters != null && !tipParameters.isEmpty() && tipParameters.get(0) != null) {
63+
if (tipParameters.get(0).getTipTokenService() != null) {
64+
token = tipParameters.get(0).getTokenValue();
65+
}
66+
if (tipParameters.get(0).getTipLoginService() != null) {
67+
loginService = tipParameters.get(0).getTipLoginService();
68+
}
5769
}
58-
if (tipParameters.get(0).getTipLoginService() != null) {
59-
loginService = tipParameters.get(0).getTipLoginService();
70+
tipURL = loginService + "/" + token + "/staff/" + userEmail;
71+
} else {
72+
// Not CGIAR User
73+
if (tipParameters != null && tipParameters.get(0) != null && tipParameters.get(0).getTipBaseUrl() != null) {
74+
tipURL = tipParameters.get(0).getTipBaseUrl();
6075
}
6176
}
62-
tipURL = loginService + "/" + token + "/staff/" + userEmail;
6377
} catch (NumberFormatException e) {
6478
LOG.error("Error getting tip URL: " + e);
6579
}

marlo-web/src/main/java/org/cgiar/ccafs/marlo/action/superadmin/TIPManagementAction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public String save() {
6363
if (tipParameter.getId() != null) {
6464
tipParameterSave.setId(tipParameter.getId());
6565
}
66+
if (tipParameter.getTipBaseUrl() != null) {
67+
tipParameterSave.setTipBaseUrl(tipParameter.getTipBaseUrl());
68+
}
6669
if (tipParameter.getTipLoginService() != null) {
6770
tipParameterSave.setTipLoginService(tipParameter.getTipLoginService());
6871
}

marlo-web/src/main/resources/custom/aicrra.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ tipParameterManagement.title=TIP Management
212212
tipParameter.privateKey=Private Key
213213
tipParameter.tipTokenService=Token Service Endpoint
214214
tipParameter.tipLoginService=Login Service Endpoint
215+
tipParameter.tipBaseUrl=Base URL
215216
tipParameter.tipStatusService= Status Service Endpoint
216217
tipParameter.tokenValue= Token Value
217218
tipParameter.updateToken= Update Token
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE tip_parameters ADD tip_base_url text NULL;

marlo-web/src/main/resources/global.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ tipParameterManagement.title=TIP Management
212212
tipParameter.privateKey=Private Key
213213
tipParameter.tipTokenService=Token Service Endpoint
214214
tipParameter.tipLoginService=Login Service Endpoint
215+
tipParameter.tipBaseUrl=Base URL
215216
tipParameter.tipStatusService= Status Service Endpoint
216217
tipParameter.tokenValue= Token Value
217218
tipParameter.updateToken= Update Token

marlo-web/src/main/webapp/WEB-INF/global/views/superadmin/tipManagement.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{"label":"tipManagement", "nameSpace":"", "action":""}
1414
]/]
1515

16+
1617
[#include "/WEB-INF/global/pages/header.ftl" /]
1718
<hr />
1819

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

3738
<div id="tipManagement" class="borderBox">
39+
<div class="form-group">
40+
[@customForm.input name="tipParameter.tipBaseUrl" i18nkey="tipParameter.tipBaseUrl" className="description limitWords-100" required=true /]
41+
</div>
3842
<div class="form-group">
3943
[@customForm.input name="tipParameter.privateKey" i18nkey="tipParameter.privateKey" className="description limitWords-100" required=true /]
4044
</div>

0 commit comments

Comments
 (0)