Revision 6994
Added by ben leinfelder almost 13 years ago
lib/metacat.properties | ||
---|---|---|
523 | 523 |
dataone.replicationpolicy.default.preferredNodeList= |
524 | 524 |
dataone.replicationpolicy.default.blockedNodeList= |
525 | 525 |
|
526 |
# overall services (TODO: mn vs. cn?) |
|
527 |
dataone.mn.services.enabled=true |
|
528 |
dataone.mn.registration.submitted=false |
|
529 |
|
|
526 | 530 |
# state which versions of each MN tier service are availalble |
527 | 531 |
dataone.mnCore.serviceAvailable=true |
528 | 532 |
dataone.mnCore.serviceVersion=v1 |
lib/admin/dataone-configuration.jsp | ||
---|---|---|
72 | 72 |
<form method="POST" name="configuration_form" action="<%= request.getContextPath() %>/admin" |
73 | 73 |
onsubmit="return submitForm(this);"> |
74 | 74 |
|
75 |
<h3>Member Node Services</h3> |
|
76 |
Enable or disable DataONE Member Node Services for this deployment |
|
77 |
|
|
78 |
<hr class="config-line"> |
|
79 |
<div class="form-row"> |
|
80 |
<img class="question-mark" src="style/images/question-mark.gif" |
|
81 |
onClick="helpWindow('<%= request.getContextPath() %>','docs/dataone.html#configuring-metacat-as-a-member-node')"/> |
|
82 |
<div class="textinput-label"><label for="dataone.mn.services.enabled" title="Enable DataONE Member Node Services">Enable DataONE Services</label></div> |
|
83 |
|
|
84 |
<% |
|
85 |
|
|
86 |
boolean enableServices = false; |
|
87 |
String enableServicesString = (String) request.getAttribute("dataone.mn.services.enabled"); |
|
88 |
if (enableServicesString != null) { |
|
89 |
enableServices = Boolean.parseBoolean(enableServicesString); |
|
90 |
} |
|
91 |
|
|
92 |
if (enableServices) { |
|
93 |
%> |
|
94 |
<input type="checkbox" |
|
95 |
class="textinput" |
|
96 |
id="dataone.mn.services.enabled" |
|
97 |
name="ddataone.mn.services.enabled" |
|
98 |
value="true" |
|
99 |
checked="checked"/> |
|
100 |
<% } else {%> |
|
101 |
<input type="checkbox" |
|
102 |
class="textinput" |
|
103 |
id="dataone.mn.services.enabled" |
|
104 |
name="dataone.mn.services.enabled" |
|
105 |
value="true"/> |
|
106 |
<% } %> |
|
107 |
|
|
108 |
</div> |
|
109 |
|
|
75 | 110 |
<h3>Member Node Configuration</h3> |
76 | 111 |
General information identifiying this node, its owner, and contents. You will need |
77 | 112 |
a certificate to identify the node, and a DataONE account to act as a node contact. |
... | ... | |
147 | 182 |
<div class="form-row"> |
148 | 183 |
<img class="question-mark" src="style/images/question-mark.gif" |
149 | 184 |
onClick="helpWindow('<%= request.getContextPath() %>','docs/dataone.html#configuring-metacat-as-a-member-node')"/> |
150 |
<div class="textinput-label"><label for="dataone.nodeSynchronize" title="Enable DataONE services by synchronizing metadata">Enable DataONE Services</label></div>
|
|
185 |
<div class="textinput-label"><label for="dataone.nodeSynchronize" title="Enable DataONE metadata synchronization">Enable Metadata Synchronization</label></div>
|
|
151 | 186 |
|
152 | 187 |
<% |
153 | 188 |
|
... | ... | |
336 | 371 |
if (isUpdateString != null) { |
337 | 372 |
isUpdate = Boolean.parseBoolean(isUpdateString); |
338 | 373 |
} |
374 |
// do we know if it is pending approval? |
|
375 |
boolean isSubmitted = false; |
|
376 |
String isSubmittedString = (String) request.getAttribute("dataone.mn.registration.submitted"); |
|
377 |
if (isSubmittedString != null) { |
|
378 |
isSubmitted = Boolean.parseBoolean(isSubmittedString); |
|
379 |
} |
|
339 | 380 |
%> |
340 | 381 |
<%if (isUpdate) { %> |
341 | 382 |
<input class=button type="submit" value="Update"/> |
383 |
<%} else if (isSubmitted) { %> |
|
384 |
<input class=button type="submit" value="Update" disabled="disabled"/> |
|
342 | 385 |
<%} else { %> |
343 | 386 |
<input class=button type="submit" value="Register"/> |
344 | 387 |
<%} %> |
345 |
<input class=button type="button" value="Skip" onClick="forward('./admin?configureType=dataone&bypass=true&processForm=true')"> |
|
388 |
<% |
|
389 |
// if have we already configured this section, then we cannot skip it |
|
390 |
boolean previouslyConfigured = false; |
|
391 |
String previouslyConfiguredString = (String) request.getAttribute("configutil.dataoneConfigured"); |
|
392 |
if (previouslyConfiguredString != null) { |
|
393 |
previouslyConfigured = Boolean.parseBoolean(previouslyConfiguredString); |
|
394 |
} |
|
395 |
%> |
|
396 |
<%if (!previouslyConfigured) { %> |
|
397 |
<input class=button type="button" value="Skip" onClick="forward('./admin?configureType=dataone&bypass=true&processForm=true')"> |
|
398 |
<%} %> |
|
346 | 399 |
<input class=button type="button" value="Cancel" onClick="forward('./admin')"> |
347 | 400 |
|
348 | 401 |
</form> |
src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java | ||
---|---|---|
74 | 74 |
import org.dataone.service.types.v1.Permission; |
75 | 75 |
import org.dataone.service.types.v1.Subject; |
76 | 76 |
import org.dataone.service.types.v1.SystemMetadata; |
77 |
import org.dataone.service.util.Constants; |
|
78 | 77 |
import org.dataone.service.util.DateTimeMarshaller; |
79 | 78 |
import org.dataone.service.util.ExceptionHandler; |
80 | 79 |
import org.dataone.service.util.TypeMarshaller; |
... | ... | |
82 | 81 |
import org.xml.sax.SAXException; |
83 | 82 |
|
84 | 83 |
import edu.ucsb.nceas.metacat.dataone.MNodeService; |
84 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
|
85 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
|
85 | 86 |
|
86 | 87 |
/** |
87 | 88 |
* MN REST service implementation handler |
... | ... | |
139 | 140 |
super(servletContext, request, response); |
140 | 141 |
logMetacat = Logger.getLogger(MNResourceHandler.class); |
141 | 142 |
} |
143 |
|
|
144 |
@Override |
|
145 |
protected boolean isD1Enabled() { |
|
146 |
|
|
147 |
boolean enabled = false; |
|
148 |
try { |
|
149 |
enabled = Boolean.parseBoolean(PropertyService.getProperty("dataone.mn.services.enabled")); |
|
150 |
} catch (PropertyNotFoundException e) { |
|
151 |
logMetacat.error("Could not check if DataONE is enabled: " + e.getMessage()); |
|
152 |
} |
|
153 |
|
|
154 |
return enabled; |
|
155 |
} |
|
142 | 156 |
|
143 | 157 |
/** |
144 | 158 |
* This function is called from REST API servlet and handles each request to the servlet |
... | ... | |
151 | 165 |
super.handle(httpVerb); |
152 | 166 |
|
153 | 167 |
try { |
168 |
|
|
169 |
// only service requests if we have D1 configured |
|
170 |
if (!isD1Enabled()) { |
|
171 |
ServiceFailure se = new ServiceFailure("0000", "DataONE services are not enabled on this node"); |
|
172 |
serializeException(se, response.getOutputStream()); |
|
173 |
return; |
|
174 |
} |
|
175 |
|
|
154 | 176 |
// get the resource |
155 | 177 |
String resource = request.getPathInfo(); |
156 | 178 |
resource = resource.substring(resource.indexOf("/") + 1); |
src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java | ||
---|---|---|
142 | 142 |
|
143 | 143 |
try { |
144 | 144 |
|
145 |
// only service requests if we have D1 configured |
|
146 |
if (!isD1Enabled()) { |
|
147 |
ServiceFailure se = new ServiceFailure("0000", "DataONE services are not enabled on this node"); |
|
148 |
serializeException(se, response.getOutputStream()); |
|
149 |
return; |
|
150 |
} |
|
151 |
|
|
145 | 152 |
// get the resource |
146 | 153 |
String resource = request.getPathInfo(); |
147 | 154 |
resource = resource.substring(resource.indexOf("/") + 1); |
src/edu/ucsb/nceas/metacat/restservice/D1ResourceHandler.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
import edu.ucsb.nceas.metacat.MetacatHandler; |
64 | 64 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
65 |
import edu.ucsb.nceas.utilities.Log; |
|
66 | 65 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
67 | 66 |
/** |
68 | 67 |
* |
... | ... | |
150 | 149 |
logMetacat.error(e.getClass() + ": " + e.getMessage(), e); |
151 | 150 |
} |
152 | 151 |
} |
152 |
|
|
153 |
/** |
|
154 |
* subclasses should provide a more useful implementation |
|
155 |
* @return |
|
156 |
*/ |
|
157 |
protected boolean isD1Enabled() { |
|
158 |
|
|
159 |
return true; |
|
160 |
} |
|
153 | 161 |
|
154 | 162 |
protected String parseTrailing(String resource, String token) { |
155 | 163 |
// get the rest |
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? |
|
185 |
// set the configuration state so we know how to render the UI page buttons |
|
186 |
// if we have already configured once, we cannot skip this page |
|
187 |
request.setAttribute("configutil.dataoneConfigured", PropertyService.getProperty("configutil.dataoneConfigured")); |
|
188 |
|
|
189 |
// do we know if this is an update, pending verification, or a new registration? |
|
186 | 190 |
memberNodeId = (String) request.getAttribute("dataone.memberNodeId"); |
187 | 191 |
boolean update = isNodeRegistered(memberNodeId); |
188 | 192 |
request.setAttribute("dataone.isUpdate", Boolean.toString(update)); |
193 |
request.setAttribute("dataone.mn.registration.submitted", PropertyService.getProperty("dataone.mn.registration.submitted")); |
|
189 | 194 |
|
195 |
// enable the services? |
|
196 |
request.setAttribute("dataone.mn.services.enabled", PropertyService.getProperty("dataone.mn.services.enabled")); |
|
197 |
|
|
190 | 198 |
// Forward the request to the JSP page |
191 | 199 |
RequestUtil.forwardRequest(request, response, "/admin/dataone-configuration.jsp", null); |
192 | 200 |
} catch (GeneralPropertyException gpe) { |
... | ... | |
279 | 287 |
replicate = Boolean.parseBoolean(nodeReplicate); |
280 | 288 |
} |
281 | 289 |
|
290 |
// enable services as a whole? |
|
291 |
boolean servicesEnabled = false; |
|
292 |
String servicesEnabledString = (String) request.getParameter("dataone.mn.services.enabled"); |
|
293 |
if (servicesEnabledString != null) { |
|
294 |
servicesEnabled = Boolean.parseBoolean(servicesEnabledString); |
|
295 |
} |
|
296 |
|
|
282 | 297 |
// process the values, checking for nulls etc.. |
283 | 298 |
if (nodeName == null ) { |
284 | 299 |
validationErrors.add("nodeName cannot be null"); |
... | ... | |
306 | 321 |
PropertyService.setPropertyNoPersist("dataone.replicationpolicy.default.preferredNodeList", preferredNodeList); |
307 | 322 |
PropertyService.setPropertyNoPersist("dataone.replicationpolicy.default.blockedNodeList", blockedNodeList); |
308 | 323 |
|
309 |
|
|
324 |
// services |
|
325 |
PropertyService.setPropertyNoPersist("dataone.mn.services.enabled", Boolean.toString(servicesEnabled)); |
|
326 |
|
|
310 | 327 |
PropertyService.persistProperties(); |
311 | 328 |
|
312 | 329 |
// Register/update as a DataONE Member Node |
... | ... | |
332 | 349 |
+ "processing system properties page: " + gpe.getMessage(); |
333 | 350 |
logMetacat.error(errorMessage); |
334 | 351 |
processingErrors.add(errorMessage); |
352 |
} catch (Exception e) { |
|
353 |
String errorMessage = "D1Admin.configureDataONE error: " + e.getMessage(); |
|
354 |
logMetacat.error(errorMessage); |
|
355 |
processingErrors.add(errorMessage); |
|
335 | 356 |
} |
336 | 357 |
|
337 | 358 |
try { |
... | ... | |
385 | 406 |
* retrieved from the getCapabilities() service, and so this should only be called |
386 | 407 |
* after the properties have been properly set up in Metacat. |
387 | 408 |
*/ |
388 |
private void registerDataONEMemberNode() { |
|
389 |
CNode cn; |
|
390 |
try { |
|
391 |
logMetacat.debug("Get the Node description."); |
|
392 |
Node node = MNodeService.getInstance(null).getCapabilities(); |
|
393 |
logMetacat.debug("Setting client certificate location."); |
|
394 |
String mnCertificatePath = PropertyService.getProperty("D1Client.certificate.file"); |
|
395 |
CertificateManager.getInstance().setCertificateLocation(mnCertificatePath); |
|
396 |
cn = D1Client.getCN(); |
|
409 |
private void registerDataONEMemberNode() throws BaseException, PropertyNotFoundException, GeneralPropertyException { |
|
410 |
|
|
411 |
logMetacat.debug("Get the Node description."); |
|
412 |
Node node = MNodeService.getInstance(null).getCapabilities(); |
|
413 |
logMetacat.debug("Setting client certificate location."); |
|
414 |
String mnCertificatePath = PropertyService.getProperty("D1Client.certificate.file"); |
|
415 |
CertificateManager.getInstance().setCertificateLocation(mnCertificatePath); |
|
416 |
CNode cn = D1Client.getCN(); |
|
417 |
|
|
418 |
// check if this is new or an update |
|
419 |
boolean update = isNodeRegistered(node.getIdentifier().getValue()); |
|
420 |
|
|
421 |
// Session is null, because the libclient code automatically sets up an |
|
422 |
// SSL session for us using the client certificate provided |
|
423 |
Session session = null; |
|
424 |
if (update) { |
|
425 |
logMetacat.debug("Updating node with DataONE. " + cn.getNodeBaseServiceUrl()); |
|
426 |
boolean result = cn.updateNodeCapabilities(session, node.getIdentifier(), node); |
|
427 |
} else { |
|
428 |
logMetacat.debug("Registering node with DataONE. " + cn.getNodeBaseServiceUrl()); |
|
429 |
NodeReference mnodeRef = cn.register(session, node); |
|
397 | 430 |
|
398 |
// check if this is new or an update |
|
399 |
boolean update = isNodeRegistered(node.getIdentifier().getValue()); |
|
431 |
String memberNodeId = mnodeRef.getValue(); |
|
432 |
String existingMemberNodeId = PropertyService.getProperty("dataone.memberNodeId"); |
|
433 |
if (!existingMemberNodeId.equals(memberNodeId)) { |
|
434 |
// update all existing system Metadata for this node id |
|
435 |
IdentifierManager.getInstance().updateAuthoritativeMemberNodeId(existingMemberNodeId, memberNodeId); |
|
436 |
} |
|
437 |
|
|
438 |
// save that we submitted registration |
|
439 |
PropertyService.setPropertyNoPersist("dataone.mn.registration.submitted", Boolean.TRUE.toString()); |
|
440 |
|
|
441 |
// save this assigned node id |
|
442 |
PropertyService.setPropertyNoPersist("dataone.memberNodeId", memberNodeId); |
|
400 | 443 |
|
401 |
// Session is null, because the libclient code automatically sets up an |
|
402 |
// SSL session for us using the client certificate provided |
|
403 |
Session session = null; |
|
404 |
if (update) { |
|
405 |
logMetacat.debug("Updating node with DataONE. " + cn.getNodeBaseServiceUrl()); |
|
406 |
boolean result = cn.updateNodeCapabilities(session, node.getIdentifier(), node); |
|
407 |
} else { |
|
408 |
logMetacat.debug("Registering node with DataONE. " + cn.getNodeBaseServiceUrl()); |
|
409 |
NodeReference mnodeRef = cn.register(session, node); |
|
410 |
|
|
411 |
String memberNodeId = mnodeRef.getValue(); |
|
412 |
String existingMemberNodeId = PropertyService.getProperty("dataone.memberNodeId"); |
|
413 |
if (!existingMemberNodeId.equals(memberNodeId)) { |
|
414 |
// update all existing system Metadata for this node id |
|
415 |
IdentifierManager.getInstance().updateAuthoritativeMemberNodeId(existingMemberNodeId, memberNodeId); |
|
416 |
} |
|
417 |
// save this assigned node id |
|
418 |
PropertyService.setProperty("dataone.memberNodeId", memberNodeId); |
|
419 |
|
|
420 |
} |
|
421 |
} catch (BaseException e) { |
|
422 |
logMetacat.warn("Could not register as node with DataONE (" + e.getCode() + "/" + e.getDetail_code() + "): " + e.getDescription()); |
|
423 |
} catch (PropertyNotFoundException e) { |
|
424 |
logMetacat.warn("Could not find the location for client certificates: " + e.getMessage()); |
|
425 |
} catch (GeneralPropertyException e) { |
|
426 |
logMetacat.warn("Could not set the assigned node id: " + e.getMessage()); |
|
427 |
} |
|
444 |
// persist the properties |
|
445 |
PropertyService.persistProperties(); |
|
446 |
} |
|
447 |
|
|
428 | 448 |
} |
429 | 449 |
|
430 | 450 |
/** |
Also available in: Unified diff
dataone configuration and registration enhancements:
include flag to disable D1 services, currently only the MN side enforces thisoften this is a client cert issue (at least for my testing)-do not allow multiple registration attempts if we have just submitted and are awaiting Node verification by the CN.
-do not allow configuration "bypass" if D1 settings have been configured previously.
-do not allow update if Node verification is pending
-report errors that occur when calling cn.register or cn.updateNodeCapabilities -