Project

General

Profile

« Previous | Next » 

Revision 6992

Show "Update" button if this MemberNodeId is already registered with DataONE, otherwise use the "Register" label

View differences:

lib/admin/dataone-configuration.jsp
328 328
 
329 329
	<input type="hidden" name="configureType" value="dataone"/>
330 330
	<input type="hidden" name="processForm" value="true"/>
331
	<input class=button type="submit" value="Register"/>
331

  
332
	<%
333
		// do we know if it is an update or a new registration?
334
		boolean isUpdate = false;
335
		String isUpdateString = (String) request.getAttribute("dataone.isUpdate");
336
		if (isUpdateString != null) {
337
			isUpdate = Boolean.parseBoolean(isUpdateString);
338
		}
339
	%>
340
	<%if (isUpdate) { %>
341
		<input class=button type="submit" value="Update"/>
342
	<%} else { %>
343
		<input class=button type="submit" value="Register"/>
344
	<%} %>
332 345
	<input class=button type="button" value="Skip" onClick="forward('./admin?configureType=dataone&bypass=true&processForm=true')">
333 346
	<input class=button type="button" value="Cancel" onClick="forward('./admin')"> 
334 347

  
src/edu/ucsb/nceas/metacat/admin/D1Admin.java
182 182
					}
183 183
				}
184 184
				
185
				// do we know if this is an update or a new registration?
186
				memberNodeId = (String) request.getAttribute("dataone.memberNodeId");
187
				boolean update = isNodeRegistered(memberNodeId);
188
				request.setAttribute("dataone.isUpdate", Boolean.toString(update));
189
				
185 190
				// Forward the request to the JSP page
186 191
				RequestUtil.forwardRequest(request, response, "/admin/dataone-configuration.jsp", null);
187 192
			} catch (GeneralPropertyException gpe) {
......
357 362
			}
358 363
		}
359 364
	}
365
	
366
	private boolean isNodeRegistered(String nodeId) {
367
		// check if this is new or an update
368
        boolean exists = false;
369
        try {
370
	        NodeList nodes = D1Client.getCN().listNodes();
371
	        for (Node n: nodes.getNodeList()) {
372
	        	if (n.getIdentifier().getValue().equals(nodeId)) {
373
	        		exists = true;
374
	        		break;
375
	        	}
376
	        }
377
        } catch (BaseException e) {
378
            logMetacat.error("Could not check for node with DataONE (" + e.getCode() + "/" + e.getDetail_code() + "): " + e.getDescription());
379
        } 
380
        return exists;
381
	}
360 382

  
361 383
	/**
362 384
	 * Register as a member node on the DataONE network.  The node description is
......
372 394
            String mnCertificatePath = PropertyService.getProperty("D1Client.certificate.file");
373 395
            CertificateManager.getInstance().setCertificateLocation(mnCertificatePath);
374 396
            cn = D1Client.getCN();
397
            
375 398
            // check if this is new or an update
376
            boolean update = false;
377
            NodeList nodes = cn.listNodes();
378
            for (Node n: nodes.getNodeList()) {
379
            	if (n.getIdentifier().getValue().equals(node.getIdentifier().getValue())) {
380
            		update = true;
381
            		break;
382
            	}
383
            }
399
            boolean update = isNodeRegistered(node.getIdentifier().getValue());
400
            
384 401
            // Session is null, because the libclient code automatically sets up an
385 402
            // SSL session for us using the client certificate provided
386 403
            Session session = null;

Also available in: Unified diff