NIHVIVO-2343 Remove hardcoded kluges for base URL, matching property and AJAX URL. Only show the proxy panel if the user has a profile and is authorized to manage the proxy.
This commit is contained in:
parent
743b96281e
commit
b7ec17856e
5 changed files with 33 additions and 9 deletions
|
@ -181,6 +181,7 @@ public abstract class UserAccountsPage {
|
||||||
map.put("firstTimeExternal",
|
map.put("firstTimeExternal",
|
||||||
UrlBuilder.getUrl("/accounts/firstTimeExternal"));
|
UrlBuilder.getUrl("/accounts/firstTimeExternal"));
|
||||||
map.put("accountsAjax", UrlBuilder.getUrl("/accountsAjax"));
|
map.put("accountsAjax", UrlBuilder.getUrl("/accountsAjax"));
|
||||||
|
map.put("sparqlQueryAjax", UrlBuilder.getUrl("/ajax/sparqlQuery"));
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageOwnProxies;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||||
|
@ -146,6 +148,11 @@ public class UserAccountsMyAccountPage extends UserAccountsPage {
|
||||||
}
|
}
|
||||||
body.put("formUrls", buildUrlsMap());
|
body.put("formUrls", buildUrlsMap());
|
||||||
|
|
||||||
|
// Could I do this without exposing this mechanism? But how to search
|
||||||
|
// for an associated profile in AJAX?
|
||||||
|
body.put("matchingProperty", SelfEditingConfiguration.getBean(vreq)
|
||||||
|
.getMatchingPropertyUri());
|
||||||
|
|
||||||
if (userAccount.isExternalAuthOnly()) {
|
if (userAccount.isExternalAuthOnly()) {
|
||||||
body.put("externalAuthOnly", Boolean.TRUE);
|
body.put("externalAuthOnly", Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
@ -155,6 +162,9 @@ public class UserAccountsMyAccountPage extends UserAccountsPage {
|
||||||
if (!confirmationCode.isEmpty()) {
|
if (!confirmationCode.isEmpty()) {
|
||||||
body.put(confirmationCode, Boolean.TRUE);
|
body.put(confirmationCode, Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
if (isProxyPanelAuthorized()) {
|
||||||
|
body.put("showProxyPanel", Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
strategy.addMoreBodyValues(body);
|
strategy.addMoreBodyValues(body);
|
||||||
|
|
||||||
|
@ -180,6 +190,12 @@ public class UserAccountsMyAccountPage extends UserAccountsPage {
|
||||||
confirmationCode = strategy.getConfirmationCode();
|
confirmationCode = strategy.getConfirmationCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isProxyPanelAuthorized() {
|
||||||
|
return PolicyHelper
|
||||||
|
.isAuthorizedForActions(vreq, new ManageOwnProxies())
|
||||||
|
&& (getProfilePage(userAccount) != null);
|
||||||
|
}
|
||||||
|
|
||||||
boolean isExternalAuthOnly() {
|
boolean isExternalAuthOnly() {
|
||||||
return (userAccount != null) && userAccount.isExternalAuthOnly();
|
return (userAccount != null) && userAccount.isExternalAuthOnly();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
function proxyProxiesPanel(p) {
|
function proxyProxiesPanel(p) {
|
||||||
var sparqlQueryUrl = '../ajax/sparqlQuery';
|
|
||||||
var matchingProperty = "http://vivoweb.org/ontology/core#scopusId"
|
|
||||||
var urlContext = 'http://localhost:8080/vivo'
|
|
||||||
|
|
||||||
var query = ""
|
var query = ""
|
||||||
+ "PREFIX fn: <http://www.w3.org/2005/xpath-functions#> \n"
|
+ "PREFIX fn: <http://www.w3.org/2005/xpath-functions#> \n"
|
||||||
+ "PREFIX auth: <http://vitro.mannlib.cornell.edu/ns/vitro/authorization#> \n"
|
+ "PREFIX auth: <http://vitro.mannlib.cornell.edu/ns/vitro/authorization#> \n"
|
||||||
|
@ -107,10 +103,11 @@ function proxyProxiesPanel(p) {
|
||||||
|
|
||||||
this.getAdditionalInfo = function(info, externalAuthId) {
|
this.getAdditionalInfo = function(info, externalAuthId) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: sparqlQueryUrl,
|
url: proxyMechanism.sparqlQueryUrl,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: {
|
data: {
|
||||||
query: moreInfoQuery.replace("%matchingProperty%", matchingProperty).replace("%externalAuthId%", externalAuthId)
|
query: moreInfoQuery.replace("%matchingProperty%", proxyMechanism.matchingProperty)
|
||||||
|
.replace("%externalAuthId%", externalAuthId)
|
||||||
},
|
},
|
||||||
complete: function(xhr, status) {
|
complete: function(xhr, status) {
|
||||||
var results = $.parseJSON(xhr.responseText);
|
var results = $.parseJSON(xhr.responseText);
|
||||||
|
@ -120,7 +117,7 @@ function proxyProxiesPanel(p) {
|
||||||
info.classLabel = parsed[0].classLabel;
|
info.classLabel = parsed[0].classLabel;
|
||||||
}
|
}
|
||||||
if ("imageUrl" in parsed[0]) {
|
if ("imageUrl" in parsed[0]) {
|
||||||
info.imageUrl = urlContext + parsed[0].imageUrl;
|
info.imageUrl = proxyMechanism.baseUrl + parsed[0].imageUrl;
|
||||||
}
|
}
|
||||||
self.displayProxyData();
|
self.displayProxyData();
|
||||||
}
|
}
|
||||||
|
@ -153,7 +150,7 @@ function proxyProxiesPanel(p) {
|
||||||
var parms = {
|
var parms = {
|
||||||
query: query,
|
query: query,
|
||||||
model: "userAccounts",
|
model: "userAccounts",
|
||||||
url: sparqlQueryUrl
|
url: proxyMechanism.sparqlQueryUrl
|
||||||
};
|
};
|
||||||
var reportSearchStatus = new searchStatusField(this.searchStatusField, 3).setText;
|
var reportSearchStatus = new searchStatusField(this.searchStatusField, 3).setText;
|
||||||
this.addAutoCompleteField.autocomplete(new proxyAutocomplete(parms, this.getProxyInfos, this.addProxyInfo, reportSearchStatus));
|
this.addAutoCompleteField.autocomplete(new proxyAutocomplete(parms, this.getProxyInfos, this.addProxyInfo, reportSearchStatus));
|
||||||
|
|
|
@ -59,7 +59,9 @@
|
||||||
|
|
||||||
<section id="my-account" role="region">
|
<section id="my-account" role="region">
|
||||||
<form id="main-form" method="POST" action="${formUrls.myAccount}" class="customForm" role="my account">
|
<form id="main-form" method="POST" action="${formUrls.myAccount}" class="customForm" role="my account">
|
||||||
<#include "userAccounts-myProxiesPanel.ftl">
|
<#if showProxyPanel?? >
|
||||||
|
<#include "userAccounts-myProxiesPanel.ftl">
|
||||||
|
</#if>
|
||||||
|
|
||||||
<label for="email-address">Email address<span class="requiredHint"> *</span></label>
|
<label for="email-address">Email address<span class="requiredHint"> *</span></label>
|
||||||
<input type="text" name="emailAddress" value="${emailAddress}" id="email-address" role="input" />
|
<input type="text" name="emailAddress" value="${emailAddress}" id="email-address" role="input" />
|
||||||
|
|
|
@ -52,6 +52,14 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/auto
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var proxyMechanism = {
|
||||||
|
baseUrl: '${urls.base}',
|
||||||
|
sparqlQueryUrl: '${formUrls.sparqlQueryAjax}',
|
||||||
|
matchingProperty: '${matchingProperty}'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery.js"></script>',
|
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/sparqlUtils.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/sparqlUtils.js"></script>',
|
||||||
'<script type="text/javascript" src="${urls.base}/js/account/accountProxyCommon.js"></script>',
|
'<script type="text/javascript" src="${urls.base}/js/account/accountProxyCommon.js"></script>',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue