Project

General

Profile

1 6543 leinfelder
<%@ page language="java"%>
2 7390 leinfelder
<%@page import="org.dataone.client.D1Client"%>
3
<%@page import="java.net.URL"%>
4 6543 leinfelder
<%
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$'
13
	 *     '$Date$'
14
	 * '$Revision$'
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 7390 leinfelder
//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 6543 leinfelder
// 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 6545 leinfelder
	if (request.getSession() != null) {
52
		sessionId = request.getSession().getId();
53
	}
54 6543 leinfelder
}
55 6545 leinfelder
if (sessionId == null || !SessionService.getInstance().isSessionRegistered(sessionId)) {
56 6543 leinfelder
	// redirect to the login page
57
	response.sendRedirect(STYLE_SKINS_URL + "/dev/login.html");
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 7391 leinfelder
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 6543 leinfelder
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 7391 leinfelder
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 6543 leinfelder
function initTabs() {
130
	$(function() {
131
		$("#tabs").tabs();
132
		$("#tabs").tabs("add", "#mapping", "Legacy account mapping");
133
	});
134
}
135
function init() {
136
	initTabs();
137 7391 leinfelder
	initDialogs();
138 6543 leinfelder
	//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 7391 leinfelder
<!-- load AJAX results here -->
151
<div id="result"></div>
152
<div id="error"></div>
153
154 6543 leinfelder
<div id="tabs">
155
	<!-- place holder for tabs -->
156
	<ul></ul>
157
158
	<div id="mapping">
159 6547 leinfelder
		<p>Use this form to connect your old KNB account to your new DataONE identity.
160
		You will need to be logged into both systems at the same time in order for the mapping to take place.
161
		</p>
162 6543 leinfelder
163 6547 leinfelder
		Your current KNB account:
164 6543 leinfelder
		<div>
165
		<%=userName %>
166
		</div>
167
		<br/>
168 6547 leinfelder
169
		Will be mapped to this DataONE account*:
170 7390 leinfelder
		<iframe id="subjectFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getSubject">
171 6543 leinfelder
		</iframe>
172 6547 leinfelder
173
		<hr/>
174
175
		1. Use this temporary DataONE token*:
176 7390 leinfelder
		<iframe id="tokenFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getToken">
177 6547 leinfelder
		</iframe>
178
		<br/>
179 6543 leinfelder
180 6547 leinfelder
181
182 7391 leinfelder
		<form action="" method="POST" id="mapForm">
183 6547 leinfelder
			2. Enter your DataONE token:
184 6543 leinfelder
			<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 7391 leinfelder
			<input type="button" value="Map Identity" onclick="performMapping()">
189 6543 leinfelder
		</form>
190 6547 leinfelder
191
		<hr/>
192
193
		<p>
194
			*If you do not see your DataONE account or DataONE token here, then you must first authenticate using CILogon.
195
		</p>
196
		<p>
197 7390 leinfelder
			<a href="<%=portalURL %>/startRequest?target=<%=STYLE_SKINS_URL%>/dataone/index.jsp">Begin Login</a>
198 6547 leinfelder
		</p>
199 6543 leinfelder
	</div>
200
201
</div>
202
</body>
203
</html>