Ignore:
Timestamp:
04/05/12 15:38:51 (12 years ago)
Author:
twagoo
Message:

Created ComponentRegistry-1.11.1. Copied from 1.11.0 and merged a number two fixes from trunk:

  • caching of w3c xml.xsd schema in validator (CMDValidate -> 1.1)
  • issue with user settings page users without user entry in database
Location:
ComponentRegistry/tags/ComponentRegistry-1.11.1
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/tags/ComponentRegistry-1.11.1

  • ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry

  • ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java

  • ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java

    r1816 r1864  
    33import clarin.cmdi.componentregistry.ComponentRegistry;
    44import clarin.cmdi.componentregistry.ComponentRegistryException;
     5import clarin.cmdi.componentregistry.ComponentRegistryResourceResolver;
    56import clarin.cmdi.componentregistry.Configuration;
    67import clarin.cmdi.componentregistry.MDMarshaller;
     
    2829
    2930public class MDValidator implements Validator {
    30 
     31   
    3132    private final static Logger LOG = LoggerFactory.getLogger(MDValidator.class);
    3233    static final String MISMATCH_ERROR = "Cannot register component as a profile or vica versa.";
     
    4950
    5051    /**
    51      *
    52      * @param input In order to validate the input is consumed. So use @see getCMDComponentSpec to get the parsed CMDComponentSpec.
     52     *
     53     * @param input In order to validate the input is consumed. So use
     54     * @see getCMDComponentSpec to get the parsed CMDComponentSpec.
    5355     * @param desc
    54      * @param registry (registry you currently used)
    55      * @param userRegistry can be null, We get user registry as well so we can give nice error messages if needed. Can be the same as @param registry
     56     * @param registry (registry you currently used)
     57     * @param userRegistry can be null, We get user registry as well so we can give nice error messages if needed. Can be the same as
     58     * @param registry
    5659     */
    5760    public MDValidator(InputStream input, AbstractDescription description, ComponentRegistry registry, ComponentRegistry userRegistry, ComponentRegistry publicRegistry) {
     
    6265        this.publicRegistry = publicRegistry;
    6366    }
    64 
     67   
    6568    @Override
    6669    public List<String> getErrorMessages() {
    6770        return errorMessages;
    6871    }
    69 
     72   
    7073    @Override
    7174    public boolean validate() {
    7275        try {
    7376            clarin.cmdi.schema.cmd.Validator validator = new clarin.cmdi.schema.cmd.Validator(new URL(Configuration.getInstance().getGeneralComponentSchema()));
     77            validator.setResourceResolver(new ComponentRegistryResourceResolver());
    7478            // We may need to reuse the input stream, so save it to a byte array first
    7579            byte[] inputBytes = getBytesFromInputStream();
     
    109113        return errorMessages.isEmpty();
    110114    }
    111 
     115   
    112116    private byte[] getBytesFromInputStream() throws IOException {
    113117        int len;
    114118        byte[] b = new byte[4096];
    115119        final ByteArrayOutputStream bOS = new ByteArrayOutputStream();
    116 
     120       
    117121        while ((len = input.read(b)) > 0) {
    118122            bOS.write(b, 0, len);
    119123        }
    120 
     124       
    121125        return bOS.toByteArray();
    122126    }
    123 
     127   
    124128    private void validateComponents(List<CMDComponentType> cmdComponents) throws ComponentRegistryException {
    125129        for (CMDComponentType cmdComponentType : cmdComponents) {
     
    128132        }
    129133    }
    130 
     134   
    131135    private void validateDescribedComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException {
    132136        checkPublicComponents(cmdComponentType);
    133137    }
    134 
     138   
    135139    private void checkPublicComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException {
    136140        if (isDefinedInSeparateFile(cmdComponentType)) {
     
    157161                    }
    158162                }
    159 
     163               
    160164            }
    161165        }
    162166    }
    163 
     167   
    164168    private boolean isDefinedInSeparateFile(CMDComponentType cmdComponentType) {
    165169        return cmdComponentType.getName() == null;
    166170    }
    167 
     171   
    168172    public CMDComponentSpec getCMDComponentSpec() {
    169173        return spec;
Note: See TracChangeset for help on using the changeset viewer.