Revision 7128
Added by ben leinfelder about 12 years ago
DocumentImpl.java | ||
---|---|---|
2555 | 2555 |
* the user that owns the document |
2556 | 2556 |
* @param groups |
2557 | 2557 |
* the groups to which user belongs |
2558 |
* @param writeAccessRules |
|
2558 | 2559 |
*/ |
2559 | 2560 |
/* |
2560 | 2561 |
* public static String write(DBConnection conn,String filename, String pub, |
... | ... | |
2569 | 2570 |
|
2570 | 2571 |
public static String write(DBConnection conn, String xmlString, String pub, |
2571 | 2572 |
Reader dtd, String action, String docid, String user, |
2572 |
String[] groups, String ruleBase, boolean needValidation) |
|
2573 |
String[] groups, String ruleBase, boolean needValidation, boolean writeAccessRules)
|
|
2573 | 2574 |
throws Exception |
2574 | 2575 |
{ |
2575 | 2576 |
//this method will be called in handleUpdateOrInsert method |
... | ... | |
2577 | 2578 |
// get server location for this doc |
2578 | 2579 |
int serverLocation = getServerLocationNumber(docid); |
2579 | 2580 |
return write(conn, xmlString, pub, dtd, action, docid, user, groups, |
2580 |
serverLocation, false, ruleBase, needValidation); |
|
2581 |
serverLocation, false, ruleBase, needValidation, writeAccessRules);
|
|
2581 | 2582 |
} |
2582 | 2583 |
|
2583 | 2584 |
/** |
... | ... | |
2608 | 2609 |
* checked upon update for a file lock. if override = false then |
2609 | 2610 |
* a document not from this server, upon update will be locked |
2610 | 2611 |
* and version checked. |
2612 |
* @param writeAccessRules |
|
2611 | 2613 |
*/ |
2612 | 2614 |
|
2613 | 2615 |
public static String write(DBConnection conn, String xmlString, String pub, |
2614 | 2616 |
Reader dtd, String action, String accnum, String user, |
2615 | 2617 |
String[] groups, int serverCode, boolean override, String ruleBase, |
2616 |
boolean needValidation) throws Exception |
|
2618 |
boolean needValidation, boolean writeAccessRules) throws Exception
|
|
2617 | 2619 |
{ |
2618 | 2620 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
2619 | 2621 |
|
... | ... | |
2685 | 2687 |
logMetacat.debug("DocumentImpl.write - initializing parser"); |
2686 | 2688 |
parser = initializeParser(conn, action, docid, xmlReader, updaterev, |
2687 | 2689 |
user, groups, pub, serverCode, dtd, ruleBase, |
2688 |
needValidation, false, null, null, encoding); |
|
2690 |
needValidation, false, null, null, encoding, writeAccessRules);
|
|
2689 | 2691 |
// false means it is not a revision doc |
2690 | 2692 |
//null, null are createdate and updatedate |
2691 | 2693 |
//null will use current time as create date time |
... | ... | |
2775 | 2777 |
String encoding = xsr.getEncoding(); |
2776 | 2778 |
|
2777 | 2779 |
parser = initializeParser(conn, action, docid, xmlReader, rev, user, groups, |
2778 |
pub, serverCode, dtd, ruleBase, needValidation, false, null, null, encoding); |
|
2780 |
pub, serverCode, dtd, ruleBase, needValidation, false, null, null, encoding, writeAccessRules);
|
|
2779 | 2781 |
// null and null are createtime and updatetime |
2780 | 2782 |
// null will create current time |
2781 | 2783 |
//false means it is not a revision doc |
... | ... | |
2962 | 2964 |
// detect encoding |
2963 | 2965 |
XmlStreamReader xsr = new XmlStreamReader(new ByteArrayInputStream(xmlString.getBytes())); |
2964 | 2966 |
String encoding = xsr.getEncoding(); |
2967 |
|
|
2968 |
// no need to write the EML-contained access rules for replication |
|
2969 |
boolean writeAccessRules = false; |
|
2965 | 2970 |
|
2966 | 2971 |
parser = initializeParser(conn, action, docid, xmlReader, rev, user, groups, |
2967 | 2972 |
pub, serverCode, dtd, ruleBase, needValidation, |
2968 |
isRevision, createDate, updateDate, encoding); |
|
2973 |
isRevision, createDate, updateDate, encoding, writeAccessRules);
|
|
2969 | 2974 |
|
2970 | 2975 |
conn.setAutoCommit(false); |
2971 | 2976 |
parser.parse(new InputSource(xmlReader)); |
... | ... | |
3460 | 3465 |
|
3461 | 3466 |
/** |
3462 | 3467 |
* Set up the parser handlers for writing the document to the database |
3468 |
* @param writeAccessRules |
|
3463 | 3469 |
*/ |
3464 | 3470 |
private static XMLReader initializeParser(DBConnection dbconn, |
3465 | 3471 |
String action, String docid, Reader xml, String rev, String user, |
3466 | 3472 |
String[] groups, String pub, int serverCode, Reader dtd, |
3467 | 3473 |
String ruleBase, boolean needValidation, boolean isRevision, |
3468 |
Date createDate, Date updateDate, String encoding) throws Exception |
|
3474 |
Date createDate, Date updateDate, String encoding, boolean writeAccessRules) throws Exception
|
|
3469 | 3475 |
{ |
3470 | 3476 |
XMLReader parser = null; |
3471 | 3477 |
try { |
... | ... | |
3480 | 3486 |
if (ruleBase != null && ruleBase.equals(EML200)) { |
3481 | 3487 |
logMetacat.info("DocumentImpl.initalizeParser - Using eml 2.0.0 parser"); |
3482 | 3488 |
chandler = new Eml200SAXHandler(dbconn, action, docid, rev, |
3483 |
user, groups, pub, serverCode, createDate, updateDate); |
|
3489 |
user, groups, pub, serverCode, createDate, updateDate, writeAccessRules);
|
|
3484 | 3490 |
chandler.setIsRevisionDoc(isRevision); |
3485 | 3491 |
chandler.setEncoding(encoding); |
3486 | 3492 |
parser.setContentHandler((ContentHandler) chandler); |
... | ... | |
3507 | 3513 |
} else if (ruleBase != null && ruleBase.equals(EML210)) { |
3508 | 3514 |
logMetacat.info("DocumentImpl.initalizeParser - Using eml 2.1.0 parser"); |
3509 | 3515 |
chandler = new Eml210SAXHandler(dbconn, action, docid, rev, |
3510 |
user, groups, pub, serverCode, createDate, updateDate); |
|
3516 |
user, groups, pub, serverCode, createDate, updateDate, writeAccessRules);
|
|
3511 | 3517 |
chandler.setIsRevisionDoc(isRevision); |
3512 | 3518 |
chandler.setEncoding(encoding); |
3513 | 3519 |
parser.setContentHandler((ContentHandler) chandler); |
... | ... | |
3534 | 3540 |
//create a DBSAXHandler object which has the revision |
3535 | 3541 |
// specification |
3536 | 3542 |
chandler = new DBSAXHandler(dbconn, action, docid, rev, user, |
3537 |
groups, pub, serverCode, createDate, updateDate); |
|
3543 |
groups, pub, serverCode, createDate, updateDate, writeAccessRules);
|
|
3538 | 3544 |
chandler.setIsRevisionDoc(isRevision); |
3539 | 3545 |
chandler.setEncoding(encoding); |
3540 | 3546 |
parser.setContentHandler((ContentHandler) chandler); |
Also available in: Unified diff
add a parameter for optionally writing EML-embedded access control rules to the Metacat DB.
https://redmine.dataone.org/issues/2584
https://redmine.dataone.org/issues/2583