Changeset 5402 for CMDIValidator/trunk/cmdi-validator-core/src/main/java/eu/clarin/cmdi/validator/extensions/CheckHandlesExtension.java
- Timestamp:
- 06/27/14 23:41:03 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMDIValidator/trunk/cmdi-validator-core/src/main/java/eu/clarin/cmdi/validator/extensions/CheckHandlesExtension.java
r5394 r5402 31 31 import eu.clarin.cmdi.validator.CMDIValidatorExtension; 32 32 import eu.clarin.cmdi.validator.CMDIValidatorInitException; 33 import eu.clarin.cmdi.validator.CMDI ValidatorWriteableResult;33 import eu.clarin.cmdi.validator.CMDIWriteableValidationReport; 34 34 import eu.clarin.cmdi.validator.utils.HandleResolver; 35 import eu.clarin.cmdi.validator.utils. SaxonLocationUtils;35 import eu.clarin.cmdi.validator.utils.LocationUtils; 36 36 37 37 public class CheckHandlesExtension extends CMDIValidatorExtension { … … 79 79 80 80 @Override 81 public void validate(XdmNode document, CMDIValidatorWriteableResult result) 81 public void validate(final XdmNode document, 82 final CMDIWriteableValidationReport report) 82 83 throws CMDIValidatorException { 83 84 try { … … 86 87 for (XdmItem item : selector) { 87 88 String handle = null; 88 final int line = SaxonLocationUtils.getLineNumber(item);89 final int column = SaxonLocationUtils.getColumnNumber(item);89 final int line = LocationUtils.getLineNumber(item); 90 final int column = LocationUtils.getColumnNumber(item); 90 91 final String h = item.getStringValue(); 91 92 if (h != null) { … … 95 96 } else { 96 97 if (!handle.equals(h)) { 97 re sult.reportWarning(line, column, "handle '" + h +98 report.reportWarning(line, column, "handle '" + h + 98 99 "' contains leading or tailing spaces " + 99 100 "within <ResourceRef> element"); … … 103 104 104 105 if (handle != null) { 105 checkHandleURISyntax( handle, result, line, column);106 } else { 107 re sult.reportError(line, column,106 checkHandleURISyntax(report, handle, line, column); 107 } else { 108 report.reportError(line, column, 108 109 "invalid handle (<ResourceRef> was empty)"); 109 110 } … … 115 116 116 117 117 private void checkHandleURISyntax( String handle,118 CMDIValidatorWriteableResult result, int line, int column)119 throws CMDIValidatorException {118 private void checkHandleURISyntax( 119 final CMDIWriteableValidationReport report, final String handle, 120 final int line, final int column) throws CMDIValidatorException { 120 121 try { 121 122 final URI uri = new URI(handle); … … 128 129 final URI actionableURI = 129 130 new URI(HDL_PROXY_HTTP, HDL_PROXY_HOST, path, null); 130 checkHandleResolves( actionableURI, result, line, column);131 checkHandleResolves(report, actionableURI, line, column); 131 132 } catch (URISyntaxException e) { 132 133 /* should not happen */ … … 136 137 } else if (URN_SCHEME.equals(uri.getScheme())) { 137 138 if (resolveHandles) { 138 re sult.reportInfo(line, column, "PID '" + handle +139 report.reportInfo(line, column, "PID '" + handle + 139 140 "' skipped, because URN resolving is not supported"); 140 141 } else { 141 re sult.reportInfo(line, column, "PID '" + handle +142 report.reportInfo(line, column, "PID '" + handle + 142 143 "' skipped, because URN sytax checking is not supported"); 143 144 } … … 146 147 if (uri.getHost() != null) { 147 148 if (!HDL_PROXY_HOST.equalsIgnoreCase(uri.getHost())) { 148 re sult.reportError(line, column,149 report.reportError(line, column, 149 150 "The URI of PID '" + handle + 150 151 "' contains an unexpected host part of '" + 151 152 uri.getHost() + "'"); 152 153 } 153 checkHandleResolves( uri, result, line, column);154 } else { 155 re sult.reportError(line, column, "The URI of PID '" +154 checkHandleResolves(report, uri, line, column); 155 } else { 156 report.reportError(line, column, "The URI of PID '" + 156 157 handle + "' is missing the host part"); 157 158 } 158 159 } else { 159 160 if (uri.getScheme() != null) { 160 re sult.reportError(line, column,161 report.reportError(line, column, 161 162 "The URI of PID '" + handle + 162 163 "' contains an unexpected schema part of '" + 163 164 uri.getScheme() + "'"); 164 165 } else { 165 re sult.reportError(line, column, "The URI of PID '" +166 report.reportError(line, column, "The URI of PID '" + 166 167 handle + "' is missing a proper schema part"); 167 168 } 168 169 } 169 170 } catch (URISyntaxException e) { 170 re sult.reportError(line, column, "PID '" + handle +171 report.reportError(line, column, "PID '" + handle + 171 172 "' is not a well-formed URI: " + e.getMessage()); 172 173 } … … 174 175 175 176 176 private void checkHandleResolves( URI uri,177 CMDIValidatorWriteableResult result, int line, int column)178 throws CMDIValidatorException {177 private void checkHandleResolves( 178 final CMDIWriteableValidationReport result, final URI uri, 179 final int line, final int column) throws CMDIValidatorException { 179 180 if (resolver != null) { 180 181 try {
Note: See TracChangeset
for help on using the changeset viewer.