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: 2012-09-24 15:41:06 -0700 (Mon, 24 Sep 2012) $'
14
	 * '$Revision: 7394 $'
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</i> account to your new DataONE identity.
161
		</p>
162

    
163
		<p>
164
		You will need to be logged into both systems at the same time in order for the mapping to take place.
165
		</p>
166

    
167
		<br/>
168

    
169
		Your current ecoinformatics account (<a href="<%=SERVLET_URL %>?action=logout&qformat=dataone">logout</a>):
170
		<div>
171
		<%=userName %>
172
		</div>
173

    
174
		<br/>
175

    
176
		Will be mapped to this DataONE account*: 
177
		<iframe id="subjectFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getSubject">
178
		</iframe>
179

    
180
		<hr/>		
181

    
182
		1. Use this temporary DataONE token*: 
183
		<iframe id="tokenFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getToken">
184
		</iframe>
185
		<br/>
186
		
187
		
188

    
189
		<form action="" method="POST" id="mapForm">
190
			2. Enter your DataONE token:
191
			<br/>
192
			<input type="text" name="token" size="50">
193
			<input type="hidden" name="secondarySubject" value="<%=userName %>">
194
			<input type="hidden" name="action" value="mapIdentity">
195
			<input type="button" value="Map Identity" onclick="performMapping()">
196
		</form>
197

    
198
		<hr/>
199

    
200
		<p>
201
			*If you do not see your DataONE account or DataONE token here, then you must first authenticate using CILogon.
202
		</p>
203
		<p>
204
			<a href="<%=portalURL %>/startRequest?target=<%=STYLE_SKINS_URL%>/dataone/index.jsp">Begin Login</a>
205
		</p>
206
	</div>
207

    
208
</div>
209
</body>
210
</html>
(5-5/8)