Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
3
    
4
    <!-- to change the content type or response encoding change the following line -->
5
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
6
    <jsp:directive.page import="edu.ucsb.nceas.metacat.client.MetacatClient"/>
7
    <jsp:directive.page import="edu.ucsb.nceas.metacat.client.MetacatFactory"/>
8
    <jsp:directive.page import="edu.ucsb.nceas.metacat.client.MetacatException"/>
9
    <jsp:directive.page import="java.util.TreeMap"/>
10
    
11
    <jsp:declaration>
12
        final String                        LDAP_DOMAIN = ",dc=ecoinformatics,dc=org";
13
        private String                      action, usr, pwd, posted_ldapUserName;
14
        private MetacatClient               metacatClient;
15
        private String                      metacatClientResponse, organization;
16
        private String                      doUploadResponse = "", sessionID = "";
17
        private String                      scope, allDocIdsSelect, deleteButton, updateButton, updateFileName;
18
        private TreeMap                     allDocIds;
19
        private String                      updateFeedback = "", docId, selectButton;
20
    </jsp:declaration>
21
    
22
    
23
    <html xmlns="http://www.w3.org/1999/xhtml">
24
        <head>
25
            
26
            <jsp:scriptlet>
27
                pwd = request.getParameter("password");
28
                organization = request.getParameter("organization");
29
                
30
                metacatClient = MetacatClient.getMetacatClient(request);
31
                    
32
                action = request.getParameter("loginAction");
33
                if (action == null || !"Scope,Delete,Update with".contains(action)) {
34
                    deleteButton = "";
35
                    updateButton = "";
36
                }
37
                
38
                usr = request.getParameter("username");
39
                if (usr == null)
40
                    usr = metacatClient.getUser();
41
                
42
                scope = request.getParameter("pathValue");
43
                if (scope == null)
44
                    scope = usr;
45
                posted_ldapUserName = "uid=" + usr + ",o=" + organization + LDAP_DOMAIN;
46
                
47
                if (action != null) {
48
                    try {
49
                        if (action.equals("Login")) {
50
                            metacatClientResponse = metacatClient.login(posted_ldapUserName, pwd);
51
                            metacatClient.setUser(usr, metacatClientResponse);
52
                            metacatClient.setLoginResponse(metacatClientResponse);
53
                            if ((sessionID = metacatClient.getSessionId()) == null)
54
                                sessionID = "";
55
                        } else if (action.equals("Logout")) {
56
                            metacatClientResponse = metacatClient.logout();
57
                            metacatClient.setUser(usr, metacatClientResponse);
58
                            metacatClient.setLoginResponse(metacatClientResponse);
59
                            metacatClient.setSessValue("allDocIdsSelect", "", request);
60
                            metacatClient.setSessValue("deleteButton", "", request);
61
                            metacatClient.setSessValue("updateButton", "", request);
62
                            metacatClient.setSessValue("updateFileName", "", request);
63
                            metacatClient.setSessValue("updateFeedback", "", request);
64
                            metacatClient.setSessValue("deleteDescrip", "", request);
65
                            metacatClient.setSessValue("selectButton", "", request);
66
                            metacatClient.setSessValue("selectedDocIdTxt", "", request);
67
                            sessionID = "";
68
                        } else if (action.equals("Scope")) {
69
                            if (!scope.equals("")) {
70
                                allDocIds = metacatClient.getSelectQueryMap(request);
71
                                allDocIdsSelect = metacatClient.mapToHtmlSelect(allDocIds, "documentIDs", "width: 240", 10);
72
                                metacatClient.setSessValue("allDocIdsSelect", allDocIdsSelect, request);
73

    
74
                                selectButton = metacatClient.htmlInput("submit", "loginAction", "Select", "button_login", 0);
75
                                metacatClient.setSessValue("selectButton", selectButton, request);
76
                                
77
                                if (allDocIds.size() > 0) {
78
                                    metacatClient.setSessValue("updateFeedback", "Select a Document Identifier from the list and press the 'Select' button to continue.", request);
79
                                } else {
80
                                    metacatClient.setSessValue("updateFeedback", "No records found.", request);
81
                                }
82
                            } else {
83
                                metacatClient.setSessValue("allDocIdsSelect", "", request);
84
                                metacatClient.setSessValue("deleteButton", "", request);
85
                                metacatClient.setSessValue("updateButton", "", request);
86
                                metacatClient.setSessValue("updateFileName", "", request);
87
                                metacatClient.setSessValue("updateFeedback", "", request);
88
                                metacatClient.setSessValue("deleteDescrip", "", request);
89
                                metacatClient.setSessValue("selectButton", "", request);
90
                                metacatClient.setSessValue("selectedDocIdTxt", "", request);
91
                            }
92
                        } else if (action.equals("Select")) {
93
                            docId = request.getParameter("documentIDs");;
94
                            metacatClient.setSessValue("docId", docId, request);
95
                            metacatClient.setSessValue("selectedDocIdTxt", "Selected Document ID: " + docId, request);
96

    
97
                            deleteButton = metacatClient.htmlInput("submit", "loginAction", "Delete", "button_login", 0);
98
                            metacatClient.setSessValue("deleteButton", deleteButton, request);
99
                            metacatClient.setSessValue("deleteDescrip", "Caution: Removes records from metacat server and, if a metadata Doc Id, any associated Doc Id records.", request);
100

    
101
                            updateButton = metacatClient.htmlInput("submit", "loginAction", "Update with", "button_login", 0);
102
                            metacatClient.setSessValue("updateButton", updateButton, request);
103

    
104
                            updateFileName = metacatClient.htmlInput("file", "updateFileName", "", "button_login", 20);
105
                            metacatClient.setSessValue("updateFileName", updateFileName, request);
106

    
107
                            metacatClient.setSessValue("updateFeedback", "Press the 'Delete' or 'Update' button to perform task to the selected document.", request);
108
                        } else if (action.equals("Delete")) {
109
                            metacatClient.clientDeleteRequest(request);
110
                            allDocIds = metacatClient.getSelectQueryMap(request);
111
                            allDocIdsSelect = metacatClient.mapToHtmlSelect(allDocIds, "documentIDs", "width: 240", 10);
112
                            metacatClient.setSessValue("allDocIdsSelect", allDocIdsSelect, request);
113
                        } else if (action.equals("Update with")) {
114
                            metacatClient.setSessValue("updateFeedback", "You pressed update (not functional yet)", request);
115
                        }
116
                    } catch (Exception ex) {
117
                        System.out.println("*** SaeonLogin.jspx ***\n" + ex);
118
                        if (action == null)
119
                            System.out.println(" ---> action is null");
120
                        else if (metacatClient == null)
121
                            System.out.println(" ---> metacatClient is null");
122
                        else if (usr == null)
123
                            System.out.println(" ---> usr is null");
124
                    }
125
                } else {
126
                    try {
127
                        doUploadResponse = metacatClient.doMetadataUpload(request);
128
                            
129
                        allDocIds = metacatClient.getSelectQueryMap(request);
130
                        allDocIdsSelect = metacatClient.mapToHtmlSelect(allDocIds, "documentIDs", "width: 240", 10);
131
                        metacatClient.setSessValue("allDocIdsSelect", allDocIdsSelect, request);
132
                    } catch (Exception ex) {
133
                        System.out.println("SaeonUpload.jspx, jsp scriptlet exception thrown:  " + ex.getMessage());
134
                    }
135
                }
136
            </jsp:scriptlet>
137
            
138
            <script type="text/javascript">
139
                
140
                function allowSubmit(formObj) {
141
                    var     result = true;
142
                    var     action = "";
143

    
144
                    action = trim(formObj.elements["loginAction"].value);
145
                    if (action == "Login") {
146
                        if (isEmpty(formObj.elements["username"])) {
147
                            result = false;
148
                            alert("User name is required");
149
                        } else if (isEmpty(formObj.elements["organization"])) {
150
                            result = false;
151
                            alert("Organization is required");
152
                        } else if (isEmpty(formObj.elements["password"])) {
153
                            result = false;
154
                            alert("Password is required");
155
                        }
156
                    }
157
                    
158
                    return(result);
159
                }
160
                
161
                function isEmpty(aTextField) {
162
                    var value = trim(aTextField.value);
163
                    var result = ((value.length == 0) || (value == null));
164
                    return(result);
165
                }
166

    
167
		function trim(stringToTrim) {
168
			return(stringToTrim.replace(/^\s+|\s+$/g,""));
169
		}
170
                
171
                function frameExists(frameName) {
172
                    var result = false;
173
                    
174
                    for (var i=0; i &lt; parent.frames.length ;i++) {
175
                        if (parent.frames[i].name == frameName)
176
                         result = true;
177
                    }
178
                    return(result);
179
                }
180
                
181
                function allowUploadSubmit(formObj) {
182
                    var     result = true;
183

    
184
                        if (isEmpty(formObj.elements["fileName"])) {
185
                            result = false;
186
                            alert("Complete file name is required");
187
                        }
188
                    }
189
                    return(result);
190
                }
191
            </script>
192
            
193
            <title>SANParks - Kruger National Park Data Repository</title>
194
            <link href="knp.css" rel="stylesheet" type="text/css"/>
195
            
196
        </head>
197
        <body>
198
            
199
            <li>Login
200
                <jsp:scriptlet>
201
                    if (!metacatClient.isLoggedIn()) {
202
                </jsp:scriptlet>
203
                <form name="loginForm" method="post" action="SaeonLogin.jspx" onsubmit="return allowSubmit(this)">
204
                    <input name="qformat" value="knp" type="hidden"/>
205
                    <table>
206
                        <tr>
207
                            <td>
208
                                <span class="required">User name</span>
209
                            </td>
210
                            <td>
211
                                <input name="username" value="" type="text" style="width: 140"/>
212
                            </td>
213
                            <td rowspan="3" class="regtext" align="right" valign="top" style="width: 160" >
214
                                <div>
215
                                    <!-- Config param follows -->
216
                                    <a href="http://localhost:8084/cgiScripts/cgi-bin/ldapweb.cgi" target="_parent">create a new account</a>
217
                                </div>
218
                            </td>
219
                        </tr>
220
                        <tr>
221
                            <td>
222
                                <span class="required">Organization</span>
223
                            </td>
224
                            <td>
225
                                <select name="organization" style="width: 140">
226
                                    <option value="SANParks" selected="">SANParks</option>
227
                                    <option value="SAEON">SAEON</option>
228
                                    <option value="NCEAS">NCEAS</option>
229
                                    <option value="unaffiliated">unaffiliated</option>
230
                                </select>
231
                            </td>
232
                        </tr>
233
                        <tr>
234
                            <td>
235
                                <span class="required">Password</span>
236
                            </td>
237
                            <td>
238
                                <input name="password" value="" type="password" style="width: 140" maxlength="50"/>
239
                            </td>
240
                        </tr>
241
                        <tr>
242
                            <td colspan="2" align="center">
243
                                <input name="loginAction" value="Login" type="submit" class="button_login"/>
244
                            </td>
245
                        </tr>
246
                    </table>
247
                </form>
248
                <jsp:scriptlet>
249
                    } else {
250
                </jsp:scriptlet>
251
                <form name="logoutForm" method="post" action="SaeonLogin.jspx">
252
                    <input name="qformat" value="knp" type="hidden"/>
253
                    <table>
254
                        <tr>
255
                            <td>
256
                                <div class="regtext">Account: <jsp:expression>metacatClient.getLoginResponseElement("name")</jsp:expression></div>
257
                            </td>
258
                            <td rowspan="2" class="regtext" align="right" valign="top" style="width: 160" >
259
                                <div>
260
                                    <!-- Config param follows -->
261
                                    <a href="http://localhost:8084/cgiScripts/cgi-bin/ldapweb.cgi?stage=resetpass" target="_parent">reset your password</a>
262
                                </div>
263
                                <div>
264
                                    <!-- Config param follows -->
265
                                    <a href="http://localhost:8084/cgiScripts/cgi-bin/ldapweb.cgi?stage=changepass" target="_parent">change your password</a>
266
                                </div>
267
                            </td>
268
                        </tr>
269
                        <tr>
270
                            <td>
271
                                <p class="regtext"><jsp:expression>metacatClient.getLoginResponseElement("message")</jsp:expression></p>
272
                            </td>
273
                        </tr>
274
                        <tr>
275
                            <td align="center">
276
                                <input name="loginAction" value="Logout" type="submit" class="button_login"/>
277
                            </td>
278
                        </tr>
279
                    </table>
280
                </form>
281
                <jsp:scriptlet>
282
                    }
283
                </jsp:scriptlet>
284
                
285
                <!-- File Upload Form -->
286
                <br/>
287
                <br/>
288
            </li>
289
            <li>Data Package Upload
290
                <br/>
291
                <jsp:scriptlet>
292
                    if (metacatClient == null || !metacatClient.isLoggedIn()) {
293
                </jsp:scriptlet>
294
                <div class="regtext">
295
                    You must be logged into your user account before uploading a data set.
296
                </div>
297
                <jsp:scriptlet>
298
                    } else {
299
                </jsp:scriptlet>
300
                <form name="uploadForm" method="post" action="SaeonLogin.jspx" enctype="multipart/form-data" 
301
                      onsubmit="return allowSubmit(this)">
302
                    <jsp:expression>metacatClient.htmlInput("hidden", "pathExpr", "/metadata/distinfo/resdesc", "", 0)</jsp:expression>
303
                    <jsp:expression>metacatClient.htmlInput("hidden", "pathValue", "bart", "", 0)</jsp:expression>
304
                    <jsp:expression>metacatClient.htmlInput("hidden", "returnfield", "distinfo/stdorder/digform/digtopt/onlinopt/computer/networka/networkr", "", 0)</jsp:expression>
305
                    <table bgcolor="WhiteSmoke">
306
                        <tr>
307
                            <td colspan="2">
308
                                <p class="regtext">Enter the Meta Data File (required) &#xa0;&#xa0;&#xa0;
309
                                    <input name="publicAccess" type="checkbox" checked=''/> Grant public read access
310
                                </p>
311
                            </td>
312
                        </tr>
313
                        <tr>
314
                            <td>
315
                                <input name="fileName" accept="xml" type="file" size="60" />
316
                            </td>
317
                        </tr>
318
                        <!-- Data fields -->
319
                        <tr>
320
                            <td colspan="2">
321
                                <p class="regtext">Enter Data File 1 (optional)</p>
322
                            </td>
323
                        </tr>
324
                        <tr>
325
                            <td colspan="2">
326
                                <input name="dataFileName1" type="file" size="60" />
327
                            </td>
328
                        </tr>
329
                        <tr>
330
                            <td colspan="2">
331
                                <p class="regtext">Enter Data File 2 (optional)</p>
332
                            </td>
333
                        </tr>
334
                        <tr>
335
                            <td colspan="2">
336
                                <input name="dataFileName2" type="file" size="60" />
337
                            </td>
338
                        </tr>
339
                        <tr>
340
                            <td colspan="2">
341
                                <p class="regtext">Enter Data File 3 (optional)</p>
342
                            </td>
343
                        </tr>
344
                        <tr>
345
                            <td colspan="2">
346
                                <input name="dataFileName3" type="file" size="60" />
347
                            </td>
348
                        </tr>
349
                        <tr>
350
                            <td colspan="2">
351
                                <p class="regtext">Enter Data File 4 (optional)</p>
352
                            </td>
353
                        </tr>
354
                        <tr>
355
                            <td colspan="2">
356
                                <input name="dataFileName4" type="file" size="60" />
357
                            </td>
358
                        </tr>
359
                        <tr>
360
                            <td colspan="2">
361
                                <p class="regtext">Enter Data File 5 (optional)</p>
362
                            </td>
363
                        </tr>
364
                        <tr>
365
                            <td colspan="2">
366
                                <input name="dataFileName5" type="file" size="60" />
367
                            </td>
368
                        </tr>
369
                        <tr>
370
                            <td align="left">
371
                                <span class="regtext"><jsp:expression>doUploadResponse</jsp:expression></span>
372
                            </td>
373
                            <td align="right">
374
                                <input name="uploadAction" value="Upload" type="submit" class="button_login"/>
375
                            </td>
376
                        </tr>
377
                    </table>
378
                </form>
379
                <jsp:scriptlet>
380
                    }
381
                </jsp:scriptlet>
382
                <br/>
383
            </li>
384
            
385
            <li>Search for KNP Data (includes restricted access data)
386
                <jsp:scriptlet>
387
                    if (metacatClient == null || !metacatClient.isLoggedIn()) {
388
                </jsp:scriptlet>
389
                <div class="regtext">
390
                    You must be logged into your user account before viewing restricted access data sets.
391
                </div>
392
                <jsp:scriptlet>
393
                    } else {
394
                </jsp:scriptlet>
395
                <form name="searchform" method="post" action="/knb/metacat" target="_top">
396
                    <jsp:include page="SimpleSearchMetacatPostFields.html"/>
397
                    <input name="qformat" value="knp" type="hidden"/>
398
                    <jsp:expression>metacatClient.htmlInput("hidden", "sessionid", sessionID, "", 0)</jsp:expression>
399
                    <br/>
400
                    <p class="regtext">
401
                        <input name="anyfield" value="" type="text" size="14"/>
402
                        <input value="Search" type="submit"/>
403
                        all fields, including author, title, abstract, keywords, and other documentation.
404
                        Use a '%' symbol as a wildcard (e.g., '%biodiversity%').
405
                    </p>
406
                </form>
407
                <jsp:scriptlet>
408
                    }
409
                </jsp:scriptlet>
410
                <br/>
411
            </li>
412
            
413
            <li>Browse KNP data sets (includes restricted access data)
414
                <jsp:scriptlet>
415
                    if (metacatClient == null || !metacatClient.isLoggedIn()) {
416
                </jsp:scriptlet>
417
                <div class="regtext">
418
                    You must be logged into your user account before viewing restricted access data sets.
419
                </div>
420
                <jsp:scriptlet>
421
                    } else {
422
                </jsp:scriptlet>
423
                <form name="browseform" method="post" action="/knb/metacat" target="_top">
424
                    <jsp:include page="SimpleSearchMetacatPostFields.html"/>
425
                    <input name="anyfield" type="hidden" value="%" />
426
                    <input name="qformat" value="knp" type="hidden"/>
427
                    <jsp:expression>metacatClient.htmlInput("hidden", "sessionid", sessionID, "", 0)</jsp:expression>
428
                    <br/>
429
                    <p class="regtext">
430
                        <input name="action" value="query" type="submit"/>
431
                        Browse all existing data sets by title.  This operation can be slow.
432
                    </p>
433
                </form>
434
                <jsp:scriptlet>
435
                    }
436
                </jsp:scriptlet>
437
                <br/>
438
            </li>
439
            
440
            <li>Update or Delete KNP data sets
441
                <jsp:scriptlet>
442
                    if (metacatClient == null || !metacatClient.isLoggedIn()) {
443
                </jsp:scriptlet>
444
                <div class="regtext">
445
                    You must be logged into your user account before updating/deleting data sets .
446
                </div>
447
                <jsp:scriptlet>
448
                    } else {
449
                </jsp:scriptlet>
450
                    <br/>
451
                        <table bgcolor="WhiteSmoke">
452
                            <tr>
453
                                <td colspan="3">
454
                                <form name="scopeForm" method="post">
455
                                    <jsp:expression>metacatClient.htmlInput("hidden", "sessionid", sessionID, "", 0)</jsp:expression>
456
                                    <jsp:expression>metacatClient.htmlInput("hidden", "pathExpr", "/metadata/distinfo/resdesc", "", 0)</jsp:expression>
457
                                    <jsp:expression>metacatClient.htmlInput("hidden", "returnfield", "distinfo/stdorder/digform/digtopt/onlinopt/computer/networka/networkr", "", 0)</jsp:expression>
458
                                    <p class="regtext">
459
                                    <jsp:expression>metacatClient.htmlInput("text", "pathValue", scope, "", 14)</jsp:expression>
460
                                    <input name="loginAction" value="Scope" type="submit" class="button_login"/>
461
                                    &#xa0;&#xa0;Get a list of existing FGDC data packages for a specified scope.&#xa0;&#xa0;
462
                                    </p>
463
                                </form>
464
                                </td>
465
                            </tr>
466
                            <tr>
467
                                <td rowspan="3">
468
                                <form name="selectionForm" method="post">
469
                                    <jsp:expression>metacatClient.htmlInput("hidden", "sessionid", sessionID, "", 0)</jsp:expression>
470
                                    <jsp:expression>metacatClient.htmlInput("hidden", "pathValue", scope, "", 0)</jsp:expression>
471
                                    <jsp:expression>metacatClient.getSessValue("allDocIdsSelect", request)</jsp:expression>
472
                                    <br/>
473
                                    <jsp:expression>metacatClient.getSessValue("selectButton", request)</jsp:expression>
474
                                </form>
475
                                </td>
476
                                <td colspan="2" align="center">
477
                                    <jsp:expression>metacatClient.getSessValue("selectedDocIdTxt", request)</jsp:expression>
478
                                </td>
479
                            </tr>
480
                            <tr>
481
                                <td>
482
                                <form name="deleteForm" method="post">
483
                                    <jsp:expression>metacatClient.htmlInput("hidden", "sessionid", sessionID, "", 0)</jsp:expression>
484
                                    <jsp:expression>metacatClient.htmlInput("hidden", "pathExpr", "/metadata/distinfo/resdesc", "", 0)</jsp:expression>
485
                                    <jsp:expression>metacatClient.htmlInput("hidden", "pathValue", scope, "", 0)</jsp:expression>
486
                                    <jsp:expression>metacatClient.htmlInput("hidden", "returnfield", "distinfo/stdorder/digform/digtopt/onlinopt/computer/networka/networkr", "", 0)</jsp:expression>
487
                                    <jsp:expression>metacatClient.getSessValue("deleteButton", request)</jsp:expression>
488
                                </form>
489
                                </td>
490
                                <td>
491
                                    <p class="regtext">
492
                                        <jsp:expression>metacatClient.getSessValue("deleteDescrip", request)</jsp:expression>
493
                                    </p>
494
                                </td>
495
                            </tr>
496
                            <tr>
497
                                <td>
498
                                <form name="updateForm" method="post">
499
                                    <jsp:expression>metacatClient.htmlInput("hidden", "sessionid", sessionID, "", 0)</jsp:expression>
500
                                    <jsp:expression>metacatClient.htmlInput("hidden", "pathExpr", "/metadata/distinfo/resdesc", "", 0)</jsp:expression>
501
                                    <jsp:expression>metacatClient.htmlInput("hidden", "pathValue", scope, "", 0)</jsp:expression>
502
                                    <jsp:expression>metacatClient.htmlInput("hidden", "returnfield", "distinfo/stdorder/digform/digtopt/onlinopt/computer/networka/networkr", "", 0)</jsp:expression>
503
                                    <jsp:expression>metacatClient.getSessValue("updateButton", request)</jsp:expression>
504
                                </form>
505
                                </td>
506
                                <td>
507
                                    <jsp:expression>metacatClient.getSessValue("updateFileName", request)</jsp:expression>
508
                                </td>
509
                            </tr>
510
                            <tr>
511
                                <td colspan="3">
512
                                    <p class="regtext">
513
                                    <jsp:expression>metacatClient.getSessValue("updateFeedback", request)</jsp:expression>
514
                                    </p>
515
                                </td>
516
                            </tr>
517
                        </table>
518
                <jsp:scriptlet>
519
                    }
520
                </jsp:scriptlet>
521
                <br/>
522
            </li>
523
        </body>
524
    </html>
525
</jsp:root>
(2-2/12)