Project

General

Profile

1
<%@ page language="java"%>
2
<%@page import="org.dataone.client.D1Client"%>
3
<%@page import="java.net.URL"%>
4
<%
5
	/**
6
	 *  '$RCSfile$'
7
	 *      Authors: Matt Jones
8
	 *    Copyright: 2008 Regents of the University of California and the
9
	 *               National Center for Ecological Analysis and Synthesis
10
	 *  For Details: http://www.nceas.ucsb.edu/
11
	 *
12
	 *   '$Author: leinfelder $'
13
	 *     '$Date: 2013-02-24 21:15:45 -0800 (Sun, 24 Feb 2013) $'
14
	 * '$Revision: 7500 $'
15
	 * 
16
	 * This is an HTML document for loading an xml document into Oracle
17
	 *
18
	 * This program is free software; you can redistribute it and/or modify
19
	 * it under the terms of the GNU General Public License as published by
20
	 * the Free Software Foundation; either version 2 of the License, or
21
	 * (at your option) any later version.
22
	 *
23
	 * This program is distributed in the hope that it will be useful,
24
	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
	 * GNU General Public License for more details.
27
	 *
28
	 * You should have received a copy of the GNU General Public License
29
	 * along with this program; if not, write to the Free Software
30
	 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31
	 */
32
%>
33

    
34
<%@ include file="../../common/common-settings.jsp"%>
35
<%@ include file="../../common/configure-check.jsp"%>
36
<%@page import="edu.ucsb.nceas.metacat.service.SessionService"%>
37
<%
38

    
39
//get the CN environment, dynamically
40
String cnURL = D1Client.getCN().getNodeBaseServiceUrl();
41
String portalURL = cnURL.substring(0, cnURL.lastIndexOf(new URL(cnURL).getPath())) + "/portal";
42
//String portalURL =  "https://cn.dataone.org/portal";
43

    
44
// what was the given DataONE identity?
45
String d1Identity = request.getParameter("d1Identity");
46
String token = request.getParameter("token");
47

    
48
// look up the username from the given session
49
String sessionId = request.getParameter("sessionId");
50
if (sessionId == null) {
51
	if (request.getSession() != null) {
52
		sessionId = request.getSession().getId();
53
	}
54
}
55
if (sessionId == null || !SessionService.getInstance().isSessionRegistered(sessionId)) {
56
	// redirect to the login page
57
	response.sendRedirect(STYLE_SKINS_URL + "/dataone/login.jsp");
58
	return;
59
}
60
String userName = SessionService.getInstance().getRegisteredSession(sessionId).getUserName();
61
%>
62

    
63
<html>
64
<head>
65
<title>Map legacy account to DataONE</title>
66

    
67
<link rel="stylesheet" type="text/css" href="<%=STYLE_COMMON_URL%>/jquery/jqueryui/css/smoothness/jquery-ui-1.8.6.custom.css">
68
<link rel="stylesheet" type="text/css" href="dataone.css" />	
69
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/jquery/jquery.js"></script>
70
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/jquery/jqueryui/js/jquery-ui-1.8.6.custom.min.js"></script>
71
<script type="text/javascript">
72

    
73

    
74
function makeAjaxCall(url, formId, divId, callback) {
75
	$('#' + divId).load(
76
		url, //url
77
		$("#" + formId).serialize(), //data
78
		function(response, status, xhr) {
79
			if (status == "error") {
80
				var msg = "Sorry but there was an error: ";
81
				$("#error").html(msg + response);
82
				$("#error").dialog('open');
83
			} else {
84
				// call the callback
85
				if (callback) {
86
					setTimeout(callback, 0);
87
				}
88
			}
89
		}
90
	);
91
}
92
function performMapping() {
93
	$('#mapForm [name="action"]').val('mapIdentity');
94
	makeAjaxCall(
95
			'performMapping.jsp', 
96
			'mapForm', 
97
			'result', 
98
			function() { $("#result").dialog('open'); });
99
	
100
}
101
function lookupToken() {
102
	var data = $('#tokenFrame').contents();
103
	$('#mapForm [name="token"]').val(data);
104
	alert('Loaded token: ' + data);
105
		
106
	  	
107
}
108
function lookupSubject() {
109
	var subjectFrame = $('#subjectFrame');
110
	var data = $('#subjectFrame').val();
111
	$('#mapForm [name="primarySubject"]').val(data);
112
	alert('Loaded subject: ' + data);
113
}
114
function initDialogs() {
115
	// make the result section a dialog (popup)
116
	$("#result").dialog(
117
			{	autoOpen: false,
118
				title: "Results",
119
				width: 450
120
			}
121
		);
122
	$("#error").dialog(
123
			{	autoOpen: false,
124
				title: "Error",
125
				width: 450
126
			}
127
		);
128
}
129
function initTabs() {
130
	$(function() {
131
		$("#tabs").tabs();
132
		$("#tabs").tabs("add", "#mapping", "Legacy account mapping");	
133
	});
134
}
135
function init() {
136
	initTabs();
137
	initDialogs();
138
	//lookupToken();
139
	//lookupSubject();
140
}
141
</script>
142

    
143
</head>
144
<body onload="init()">
145
<!-- dataone logo header -->
146
<div class="logoheader">
147
	<h1></h1>
148
</div>
149

    
150
<!-- load AJAX results here -->
151
<div id="result"></div>
152
<div id="error"></div>
153

    
154
<div id="tabs">
155
	<!-- place holder for tabs -->
156
	<ul></ul>
157

    
158
	<div id="mapping">
159
		<p>
160
		Use this form to connect your old <i>ecoinformatics account</i> to your new <i>CILogon identity</i>.
161
		(<a href="<%=portalURL %>/index.jsp">register</a> with DataONE)
162
		</p>
163

    
164
		Your current ecoinformatics account (<a href="<%=SERVLET_URL %>?action=logout&qformat=dataone">switch</a> to another account):
165
		<div>
166
		<%=userName %>
167
		</div>
168

    
169
		<br/>
170

    
171
		Will be mapped to this CILogon identity (<a href="<%=portalURL %>/startRequest?target=<%=STYLE_SKINS_URL%>/dataone/index.jsp">login</a>): 
172
		<iframe style="body {font-weight: bold}" id="subjectFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getSubject">
173
		</iframe>
174
		
175
		<hr/>		
176

    
177
		Enter this temporary token: 
178
		<iframe id="tokenFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getToken">
179
		</iframe>
180
		<br/>
181

    
182
		<form action="" method="POST" id="mapForm">
183
			In the box below:
184
			<br/>
185
			<input type="text" name="token" size="50">
186
			<input type="hidden" name="secondarySubject" value="<%=userName %>">
187
			<input type="hidden" name="action" value="mapIdentity">
188
			<input type="button" value="Map Identity" onclick="performMapping()">
189
		</form>
190

    
191
		<hr/>
192

    
193
	</div>
194

    
195
</div>
196
</body>
197
</html>
(6-6/9)