Revision 9583
Added by Jing Tao about 8 years ago
DocumentImpl.java | ||
---|---|---|
2657 | 2657 |
|
2658 | 2658 |
public static String write(DBConnection conn, String xmlString, String pub, |
2659 | 2659 |
Reader dtd, String action, String docid, String user, |
2660 |
String[] groups, String ruleBase, boolean needValidation, boolean writeAccessRules, byte[] xmlBytes) |
|
2660 |
String[] groups, String ruleBase, boolean needValidation, boolean writeAccessRules, byte[] xmlBytes, String formatId)
|
|
2661 | 2661 |
throws Exception |
2662 | 2662 |
{ |
2663 | 2663 |
//this method will be called in handleUpdateOrInsert method |
... | ... | |
2665 | 2665 |
// get server location for this doc |
2666 | 2666 |
int serverLocation = getServerLocationNumber(docid); |
2667 | 2667 |
return write(conn, xmlString, pub, dtd, action, docid, user, groups, |
2668 |
serverLocation, false, ruleBase, needValidation, writeAccessRules, xmlBytes); |
|
2668 |
serverLocation, false, ruleBase, needValidation, writeAccessRules, xmlBytes, formatId);
|
|
2669 | 2669 |
} |
2670 | 2670 |
|
2671 | 2671 |
/** |
... | ... | |
2702 | 2702 |
public static String write(DBConnection conn, String xmlString, String pub, |
2703 | 2703 |
Reader dtd, String action, String accnum, String user, |
2704 | 2704 |
String[] groups, int serverCode, boolean override, String ruleBase, |
2705 |
boolean needValidation, boolean writeAccessRules, byte[] xmlBytes) throws Exception |
|
2705 |
boolean needValidation, boolean writeAccessRules, byte[] xmlBytes, String formatId) throws Exception
|
|
2706 | 2706 |
{ |
2707 | 2707 |
// NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT |
2708 | 2708 |
|
... | ... | |
2789 | 2789 |
logMetacat.debug("DocumentImpl.write - initializing parser"); |
2790 | 2790 |
parser = initializeParser(conn, action, docid, xmlReader, updaterev, |
2791 | 2791 |
user, groups, pub, serverCode, dtd, ruleBase, |
2792 |
needValidation, false, null, null, encoding, writeAccessRules, guidsToSync); |
|
2792 |
needValidation, false, null, null, encoding, writeAccessRules, guidsToSync, formatId);
|
|
2793 | 2793 |
// false means it is not a revision doc |
2794 | 2794 |
//null, null are createdate and updatedate |
2795 | 2795 |
//null will use current time as create date time |
... | ... | |
2893 | 2893 |
Vector<String>guidsToSync = new Vector<String>(); |
2894 | 2894 |
|
2895 | 2895 |
parser = initializeParser(conn, action, docid, xmlReader, rev, user, groups, |
2896 |
pub, serverCode, dtd, ruleBase, needValidation, false, null, null, encoding, writeAccessRules, guidsToSync); |
|
2896 |
pub, serverCode, dtd, ruleBase, needValidation, false, null, null, encoding, writeAccessRules, guidsToSync, formatId);
|
|
2897 | 2897 |
// null and null are createtime and updatetime |
2898 | 2898 |
// null will create current time |
2899 | 2899 |
//false means it is not a revision doc |
... | ... | |
3037 | 3037 |
String pub, Reader dtd, String action, String accnum, String user, |
3038 | 3038 |
String[] groups, String homeServer, String notifyServer, |
3039 | 3039 |
String ruleBase, boolean needValidation, String tableName, |
3040 |
boolean timedReplication, Date createDate, Date updateDate) throws Exception |
|
3040 |
boolean timedReplication, Date createDate, Date updateDate, String formatId) throws Exception
|
|
3041 | 3041 |
{ |
3042 | 3042 |
// Get the xml as a string so we can write to file later |
3043 | 3043 |
StringReader xmlReader = new StringReader(xmlString); |
... | ... | |
3105 | 3105 |
|
3106 | 3106 |
parser = initializeParser(conn, action, docid, xmlReader, rev, user, groups, |
3107 | 3107 |
pub, serverCode, dtd, ruleBase, needValidation, |
3108 |
isRevision, createDate, updateDate, encoding, writeAccessRules, guidsToSync); |
|
3108 |
isRevision, createDate, updateDate, encoding, writeAccessRules, guidsToSync, formatId);
|
|
3109 | 3109 |
|
3110 | 3110 |
conn.setAutoCommit(false); |
3111 | 3111 |
parser.parse(new InputSource(xmlReader)); |
... | ... | |
3721 | 3721 |
String action, String docid, Reader xml, String rev, String user, |
3722 | 3722 |
String[] groups, String pub, int serverCode, Reader dtd, |
3723 | 3723 |
String ruleBase, boolean needValidation, boolean isRevision, |
3724 |
Date createDate, Date updateDate, String encoding, boolean writeAccessRules, Vector<String> guidsToSync) throws Exception |
|
3724 |
Date createDate, Date updateDate, String encoding, boolean writeAccessRules, Vector<String> guidsToSync, String formatId) throws Exception
|
|
3725 | 3725 |
{ |
3726 | 3726 |
XMLReader parser = null; |
3727 | 3727 |
try { |
... | ... | |
3751 | 3751 |
// From DB to find the register external schema location |
3752 | 3752 |
String externalSchemaLocation = null; |
3753 | 3753 |
// SchemaLocationResolver resolver = new SchemaLocationResolver(); |
3754 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocationString(); |
|
3755 |
logMetacat.debug("DocumentImpl.initalizeParser - 2.0.0 external schema location: " + externalSchemaLocation); |
|
3754 |
logMetacat.debug("DocumentImpl.initalizeParser - the final formatId of the object "+docid+" is "+formatId); |
|
3755 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocation(formatId); |
|
3756 |
if(externalSchemaLocation == null) { |
|
3757 |
logMetacat.info("DocumentImpl.initalizeParser - there is no register schemas for the formatid "+ formatId+". So we will use the old way."+ |
|
3758 |
" Put all registred schema/location paris for the validation."); |
|
3759 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocationStringWithoutFormatId(); |
|
3760 |
|
|
3761 |
} |
|
3762 |
logMetacat.info("DocumentImpl.initalizeParser - 2.0.0 external schema location: " + externalSchemaLocation); |
|
3756 | 3763 |
// Set external schemalocation. |
3757 | 3764 |
if (externalSchemaLocation != null |
3758 | 3765 |
&& !(externalSchemaLocation.trim()).equals("")) { |
3759 | 3766 |
parser.setProperty(EXTERNALSCHEMALOCATIONPROPERTY, |
3760 | 3767 |
externalSchemaLocation); |
3768 |
} else { |
|
3769 |
throw new Exception ("The schema for the format id "+formatId+" can't be found in any place. So we can't validate the xml instance."); |
|
3761 | 3770 |
} |
3762 | 3771 |
logMetacat.debug("DocumentImpl.initalizeParser - 2.0.0 parser configured"); |
3763 | 3772 |
} else if (ruleBase != null && ruleBase.equals(EML210)) { |
... | ... | |
3777 | 3786 |
parser.setFeature(SCHEMAVALIDATIONFEATURE, true); |
3778 | 3787 |
// From DB to find the register external schema location |
3779 | 3788 |
String externalSchemaLocation = null; |
3780 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocationString(); |
|
3781 |
logMetacat.debug("DocumentImpl.initalizeParser - 2.1.0 external schema location: " + externalSchemaLocation); |
|
3789 |
logMetacat.debug("DocumentImpl.initalizeParser - the final formatId of the object "+docid+" is "+formatId); |
|
3790 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocation(formatId); |
|
3791 |
if(externalSchemaLocation == null) { |
|
3792 |
logMetacat.info("DocumentImpl.initalizeParser - there is no register schemas for the formatid "+ formatId+". So we will use the old way."+ |
|
3793 |
" Put all registred schema/location paris for the validation."); |
|
3794 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocationStringWithoutFormatId(); |
|
3795 |
|
|
3796 |
} |
|
3797 |
logMetacat.info("DocumentImpl.initalizeParser - 2.1.0 external schema location: " + externalSchemaLocation); |
|
3782 | 3798 |
// Set external schemalocation. |
3783 | 3799 |
if (externalSchemaLocation != null |
3784 | 3800 |
&& !(externalSchemaLocation.trim()).equals("")) { |
3785 | 3801 |
parser.setProperty(EXTERNALSCHEMALOCATIONPROPERTY, |
3786 | 3802 |
externalSchemaLocation); |
3803 |
} else { |
|
3804 |
throw new Exception ("The schema for the format id "+formatId+" can't be found in any place. So we can't validate the xml instance."); |
|
3787 | 3805 |
} |
3788 | 3806 |
logMetacat.debug("DocumentImpl.initalizeParser - Using eml 2.1.0 parser configured"); |
3789 | 3807 |
} else { |
... | ... | |
3818 | 3836 |
} |
3819 | 3837 |
// From DB to find the register external schema location |
3820 | 3838 |
String externalSchemaLocation = null; |
3821 |
externalSchemaLocation = xmlss.getNameSpaceAndLocationString(); |
|
3822 |
logMetacat.debug("DocumentImpl.initalizeParser - Generic external schema location: " + externalSchemaLocation); |
|
3839 |
logMetacat.debug("DocumentImpl.initalizeParser - the final formatId of the object "+docid+" is "+formatId); |
|
3840 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocation(formatId); |
|
3841 |
if(externalSchemaLocation == null) { |
|
3842 |
logMetacat.info("DocumentImpl.initalizeParser - there is no register schemas for the formatid "+ formatId+". So we will use the old way."+ |
|
3843 |
" Put all registred schema/location paris for the validation."); |
|
3844 |
externalSchemaLocation = XMLSchemaService.getInstance().getNameSpaceAndLocationStringWithoutFormatId(); |
|
3845 |
|
|
3846 |
} |
|
3847 |
logMetacat.info("DocumentImpl.initalizeParser - Generic external schema location: " + externalSchemaLocation); |
|
3823 | 3848 |
// Set external schemalocation. |
3824 | 3849 |
if (externalSchemaLocation != null |
3825 | 3850 |
&& !(externalSchemaLocation.trim()).equals("")) { |
3826 | 3851 |
parser.setProperty(EXTERNALSCHEMALOCATIONPROPERTY, |
3827 | 3852 |
externalSchemaLocation); |
3853 |
} else { |
|
3854 |
throw new Exception ("The schema for the format id "+formatId+" can't be found in any place. So we can't validate the xml instance."); |
|
3828 | 3855 |
} |
3829 | 3856 |
|
3830 | 3857 |
} else if (ruleBase != null && ruleBase.equals(DTD) |
Also available in: Unified diff
If a format id in the system metadata is registered in the xml_catalog table, we will use the schema location for the format id to validate the xml instance;
otherwise, we will use our previous way.