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;
|
Show "Update" button if this MemberNodeId is already registered with DataONE, otherwise use the "Register" label