Revision 8509
Added by Peter Slaughter almost 11 years ago
src/edu/ucsb/nceas/metacat/MetacatHandler.java | ||
---|---|---|
3 | 3 |
* Copyright: 2010 Regents of the University of California and the |
4 | 4 |
* National Center for Ecological Analysis and Synthesis |
5 | 5 |
* |
6 |
* '$Author: jones $'
|
|
7 |
* '$Date: 2010-02-03 17:58:12 -0900 (Wed, 03 Feb 2010) $'
|
|
8 |
* '$Revision: 5211 $'
|
|
6 |
* '$Author$' |
|
7 |
* '$Date$' |
|
8 |
* '$Revision$' |
|
9 | 9 |
* |
10 | 10 |
* This program is free software; you can redistribute it and/or modify |
11 | 11 |
* it under the terms of the GNU General Public License as published by |
... | ... | |
40 | 40 |
import java.io.StringReader; |
41 | 41 |
import java.io.UnsupportedEncodingException; |
42 | 42 |
import java.io.Writer; |
43 |
import java.math.BigInteger; |
|
43 | 44 |
import java.net.MalformedURLException; |
44 | 45 |
import java.net.URL; |
45 | 46 |
import java.sql.PreparedStatement; |
... | ... | |
48 | 49 |
import java.sql.Timestamp; |
49 | 50 |
import java.text.ParseException; |
50 | 51 |
import java.text.SimpleDateFormat; |
52 |
import java.util.ArrayList; |
|
53 |
import java.util.Arrays; |
|
51 | 54 |
import java.util.Enumeration; |
52 | 55 |
import java.util.HashMap; |
53 | 56 |
import java.util.Hashtable; |
... | ... | |
68 | 71 |
import org.apache.commons.io.IOUtils; |
69 | 72 |
import org.apache.commons.io.input.XmlStreamReader; |
70 | 73 |
import org.apache.log4j.Logger; |
74 |
import org.dataone.client.CNode; |
|
75 |
import org.dataone.client.D1Client; |
|
76 |
import org.dataone.service.exceptions.NotAuthorized; |
|
77 |
import org.dataone.service.exceptions.ServiceFailure; |
|
78 |
import org.dataone.service.types.v1.AccessPolicy; |
|
71 | 79 |
import org.dataone.service.types.v1.Event; |
72 | 80 |
import org.dataone.service.types.v1.Identifier; |
81 |
import org.dataone.service.types.v1.Session; |
|
73 | 82 |
import org.dataone.service.types.v1.SystemMetadata; |
74 | 83 |
import org.ecoinformatics.eml.EMLParser; |
75 | 84 |
|
... | ... | |
89 | 98 |
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines; |
90 | 99 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
91 | 100 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
101 |
import edu.ucsb.nceas.metacat.dataone.SyncAccessPolicy; |
|
92 | 102 |
import edu.ucsb.nceas.metacat.dataone.SystemMetadataFactory; |
93 | 103 |
import edu.ucsb.nceas.metacat.dataone.hazelcast.HazelcastService; |
94 | 104 |
import edu.ucsb.nceas.metacat.dataquery.DataQuery; |
... | ... | |
3331 | 3341 |
String success = null; |
3332 | 3342 |
boolean isEmlPkgMember = false; |
3333 | 3343 |
|
3344 |
SystemMetadata mnSysMeta = null; |
|
3345 |
Session session = null; |
|
3346 |
Identifier pid = new Identifier(); |
|
3347 |
AccessPolicy mnAccessPolicy = null; |
|
3348 |
SystemMetadata cnSysMeta = null; |
|
3349 |
|
|
3334 | 3350 |
String[] docList = params.get("docid"); |
3335 | 3351 |
String[] principalList = params.get("principal"); |
3336 | 3352 |
String[] permissionList = params.get("permission"); |
... | ... | |
3357 | 3373 |
|
3358 | 3374 |
// force hazelcast to update system metadata |
3359 | 3375 |
HazelcastService.getInstance().refreshSystemMetadataEntry(docList[0]); |
3360 |
|
|
3376 |
|
|
3377 |
// Update the CN with the modified access policy |
|
3378 |
logMetacat.debug("Setting CN access policy for pid: " + docList[0]); |
|
3379 |
|
|
3380 |
try { |
|
3381 |
ArrayList<String> guids = new ArrayList<String>(Arrays.asList(docList[0])); |
|
3382 |
SyncAccessPolicy syncAP = new SyncAccessPolicy(); |
|
3383 |
|
|
3384 |
logMetacat.debug("Trying to syncing access policy for pids: " |
|
3385 |
+ docList[0]); |
|
3386 |
syncAP.sync(guids); |
|
3387 |
} catch (Exception e) { |
|
3388 |
logMetacat.error("Error syncing pids: " + docList[0] |
|
3389 |
+ " Exception " + e.getMessage()); |
|
3390 |
e.printStackTrace(System.out); |
|
3391 |
} |
|
3361 | 3392 |
} catch(AccessControlException ace) { |
3362 | 3393 |
errorList.addElement("MetacatHandler.handleSetAccessAction - " + |
3363 | 3394 |
"access control error when setting " + |
... | ... | |
3410 | 3441 |
// handle every accessionNumber |
3411 | 3442 |
for (int i = 0; i < docList.length; i++) { |
3412 | 3443 |
String docid = docList[i]; |
3444 |
|
|
3413 | 3445 |
if (docid.startsWith("urn:")) { |
3414 | 3446 |
try { |
3415 | 3447 |
String actualDocId = LSIDUtil.getDocId(docid, false); |
... | ... | |
3492 | 3524 |
// force hazelcast to update system metadata |
3493 | 3525 |
HazelcastService.getInstance().refreshSystemMetadataEntry(docList[0]); |
3494 | 3526 |
|
3527 |
logMetacat.debug("Setting CN access policy for pid: " + docList[0]); |
|
3528 |
|
|
3529 |
try { |
|
3530 |
ArrayList<String> guids = new ArrayList<String>(Arrays.asList(docList[0])); |
|
3531 |
SyncAccessPolicy syncAP = new SyncAccessPolicy(); |
|
3532 |
|
|
3533 |
logMetacat.debug("Trying to syncing access policy for pids: " |
|
3534 |
+ docList[0]); |
|
3535 |
syncAP.sync(guids); |
|
3536 |
} catch (Exception e) { |
|
3537 |
logMetacat.error("Error syncing pids: " + docList[0] |
|
3538 |
+ " Exception " + e.getMessage()); |
|
3539 |
e.printStackTrace(System.out); |
|
3540 |
} |
|
3541 |
|
|
3495 | 3542 |
//force replication when this action is called |
3496 | 3543 |
boolean isXml = true; |
3497 | 3544 |
if (publicId.equalsIgnoreCase("BIN")) { |
3498 | 3545 |
Also available in: Unified diff
When a docid's access policy is modified with metacat native api, update CN with the new access policy