use of org.akaza.openclinica.service.pmanage.Authorization in project OpenClinica by OpenClinica.
the class EnketoUrlService method getRedirectUrl.
private String getRedirectUrl(String studySubjectOid, String studyOid) {
String portalURL = CoreResources.getField("portalURL");
String url = "";
if (portalURL != null && !portalURL.equals("")) {
ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
Authorization pManageAuthorization = registrar.getAuthorization(studyOid);
try {
URL pManageUrl = new URL(portalURL);
if (pManageAuthorization != null && pManageAuthorization.getStudy() != null && pManageAuthorization.getStudy().getHost() != null && !pManageAuthorization.getStudy().getHost().equals("")) {
url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
}
} catch (MalformedURLException e) {
logger.error("Error building redirect URL: " + e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
return "";
}
}
if (!url.equals(""))
url = url + "/#/event/" + studySubjectOid + "/dashboard";
return url;
}
use of org.akaza.openclinica.service.pmanage.Authorization in project OpenClinica by OpenClinica.
the class EditFormController method getRedirectUrl.
private String getRedirectUrl(String studySubjectOid, String studyOid) {
String portalURL = CoreResources.getField("portalURL");
String url = "";
if (portalURL != null && !portalURL.equals("")) {
ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
Authorization pManageAuthorization = registrar.getAuthorization(studyOid);
try {
URL pManageUrl = new URL(portalURL);
if (pManageAuthorization != null && pManageAuthorization.getStudy() != null && pManageAuthorization.getStudy().getHost() != null && !pManageAuthorization.getStudy().getHost().equals("")) {
url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
}
} catch (MalformedURLException e) {
logger.error("Error building redirect URL: " + e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
return "";
}
}
if (!url.equals(""))
url = url + "/#/event/" + studySubjectOid + "/dashboard";
return url;
}
use of org.akaza.openclinica.service.pmanage.Authorization in project OpenClinica by OpenClinica.
the class EnketoCredentials method getInstance.
public static EnketoCredentials getInstance(String studyOid) {
EnketoCredentials credentials = new EnketoCredentials();
String pManageUrl = CoreResources.getField("portalURL") + "/app/rest/oc/authorizations";
String ocUrl = CoreResources.getField("sysURL.base") + "rest2/openrosa/" + studyOid;
RestTemplate rest = new RestTemplate();
try {
Authorization[] response = rest.getForObject(pManageUrl + "?studyoid=" + studyOid + "&instanceurl=" + ocUrl, Authorization[].class);
if (response.length > 0) {
credentials.setServerUrl(response[0].getPformUrl());
credentials.setApiKey(response[0].getPformApiKey());
credentials.setOcInstanceUrl(ocUrl);
} else {
logger.error("Unexpected response received from Participant Portal while retrieving PForm credentials. Returning empty credentials.");
}
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
logger.error("Unexpected Exception received from Participant Portal while retrieving PForm credentials: " + e.getMessage() + ". Returning empty credentials.");
}
return credentials;
}
use of org.akaza.openclinica.service.pmanage.Authorization in project OpenClinica by OpenClinica.
the class EnketoCredentials method getInstance.
public static EnketoCredentials getInstance(String studyOid) {
Study study = getParentStudy(studyOid);
studyOid = study.getOc_oid();
EnketoCredentials credentials = new EnketoCredentials();
String pManageUrl = CoreResources.getField("portalURL") + "/app/rest/oc/authorizations";
String ocUrl = CoreResources.getField("sysURL.base") + "rest2/openrosa/" + studyOid;
RestTemplate rest = new RestTemplate();
try {
Authorization[] response = rest.getForObject(pManageUrl + "?studyoid=" + studyOid + "&instanceurl=" + ocUrl, Authorization[].class);
if (response.length > 0) {
credentials.setServerUrl(response[0].getPformUrl());
credentials.setApiKey(response[0].getPformApiKey());
credentials.setOcInstanceUrl(ocUrl);
} else {
logger.error("Unexpected response received from Participant Portal while retrieving PForm credentials. Returning empty credentials.");
}
} catch (Exception e) {
logger.error(e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
logger.error("Unexpected Exception received from Participant Portal while retrieving PForm credentials: " + e.getMessage() + ". Returning empty credentials.");
}
return credentials;
}
use of org.akaza.openclinica.service.pmanage.Authorization in project OpenClinica by OpenClinica.
the class SecureController method baseUrl.
protected void baseUrl() throws MalformedURLException {
String portalURL = CoreResources.getField("portalURL");
URL pManageUrl = new URL(portalURL);
ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
Authorization pManageAuthorization = registrar.getAuthorization(currentStudy.getOid());
String url = "";
if (pManageAuthorization != null)
url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
System.out.println("the url : " + url);
request.setAttribute("participantUrl", url + "/");
}
Aggregations