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
                            docId = metacatClient.getSessValue("docId", request);
110
                            try {
111
                                updateFeedback = metacatClient.delete(docId);
112
                            } catch (MetacatException ex) {
113
                                System.out.println("*** SaeonLogin.jspx ***\n" + ex);
114
                            }
115
                            updateFeedback += metacatClient.removeDataDocIdFromFGDC(request);                            
116
                            metacatClient.setSessValue("updateFeedback", updateFeedback, request);
117
                            allDocIds = metacatClient.getSelectQueryMap(request);
118
                            allDocIdsSelect = metacatClient.mapToHtmlSelect(allDocIds, "documentIDs", "width: 240", 10);
119
                            metacatClient.setSessValue("allDocIdsSelect", allDocIdsSelect, request);
120
                        } else if (action.equals("Update with")) {
121
                            metacatClient.setSessValue("updateFeedback", "You pressed update (not functional yet)", request);
122
                        }
123
                    } catch (Exception ex) {
124
                        System.out.println("*** SaeonLogin.jspx ***\n" + ex);
125
                        if (action == null)
126
                            System.out.println(" ---> action is null");
127
                        else if (metacatClient == null)
128
                            System.out.println(" ---> metacatClient is null");
129
                        else if (usr == null)
130
                            System.out.println(" ---> usr is null");
131
                    }
132
                } else {
133
                    try {
134
                        doUploadResponse = metacatClient.doMetadataUpload(request);
135
                            
136
                        allDocIds = metacatClient.getSelectQueryMap(request);
137
                        allDocIdsSelect = metacatClient.mapToHtmlSelect(allDocIds, "documentIDs", "width: 240", 10);
138
                        metacatClient.setSessValue("allDocIdsSelect", allDocIdsSelect, request);
139
                    } catch (Exception ex) {
140
                        System.out.println("SaeonUpload.jspx, jsp scriptlet exception thrown:  " + ex.getMessage());
141
                    }
142
                }
143
            </jsp:scriptlet>
144
            
145
            <script type="text/javascript">
146
                
147
                function allowSubmit(formObj) {
148
                    var     result = true;
149
                    var     action = "";
150

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

    
174
		function trim(stringToTrim) {
175
			return(stringToTrim.replace(/^\s+|\s+$/g,""));
176
		}
177
                
178
                function frameExists(frameName) {
179
                    var result = false;
180
                    
181
                    for (var i=0; i &lt; parent.frames.length ;i++) {
182
                        if (parent.frames[i].name == frameName)
183
                         result = true;
184
                    }
185
                    return(result);
186
                }
187
                
188
                function allowUploadSubmit(formObj) {
189
                    var     result = true;
190

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