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:
7 edited
2 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/MDMarshaller.java

    r1816 r1864  
    4141    private final static Logger LOG = LoggerFactory.getLogger(MDMarshaller.class);
    4242    /**
    43      * I define W3C_XML_SCHEMA_NS_URI here cannot get it from @see XMLConstants there is a conflict between stax-api and java5.
     43     * I define W3C_XML_SCHEMA_NS_URI here cannot get it from
     44     *
     45     * @see XMLConstants there is a conflict between stax-api and java5.
    4446     */
    4547    private static final String W3C_XML_SCHEMA_NS_URI = "http://www.w3.org/2001/XMLSchema";
     
    6567
    6668    /**
    67      * 
     69     *
    6870     * @param docClass
    6971     * @param inputStream
     
    102104    }
    103105
    104     public static Schema getCMDComponentSchema() {
     106    public static synchronized Schema getCMDComponentSchema() {
    105107        if (generalComponentSchema == null) {
    106108            try {
    107109                SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
    108                 schemaFactory.setResourceResolver(new LSResourceResolver() {
    109                     private CatalogResolver catRes = new CatalogResolver();
    110 
    111                     @Override
    112                     public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    113                         InputSource resolveEntity = catRes.resolveEntity(publicId, systemId);
    114                         resolveEntity.setEncoding("UTF-8");
    115                         DOMImplementationLS domImplementation;
    116                         try {
    117                             domImplementation = (DOMImplementationLS) DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
    118                         } catch (ClassCastException e) {
    119                             throw new RuntimeException(e);
    120                         } catch (ClassNotFoundException e) {
    121                             throw new RuntimeException(e);
    122                         } catch (InstantiationException e) {
    123                             throw new RuntimeException(e);
    124                         } catch (IllegalAccessException e) {
    125                             throw new RuntimeException(e);
    126                         }
    127                         LSInput lsInput = domImplementation.createLSInput();
    128                         lsInput.setEncoding("UTF-8");
    129                         lsInput.setByteStream(resolveEntity.getByteStream());
    130                         lsInput.setCharacterStream(resolveEntity.getCharacterStream());
    131                         return lsInput;
    132                     }
    133                 });
     110                schemaFactory.setResourceResolver(new ComponentRegistryResourceResolver());
    134111                generalComponentSchema = schemaFactory.newSchema(new URL(Configuration.getInstance().getGeneralComponentSchema()));
    135112            } catch (MalformedURLException e) {
     
    169146    }
    170147
    171    
    172    
    173148    private static String getSpecId(CMDComponentSpec spec) {
    174149        String result = "";
  • ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/UserSettingsPage.java

    r1779 r1864  
    55package clarin.cmdi.componentregistry.frontend;
    66
     7import clarin.cmdi.componentregistry.ComponentRegistryFactory;
     8import clarin.cmdi.componentregistry.UserCredentials;
    79import clarin.cmdi.componentregistry.impl.database.UserDao;
    810import clarin.cmdi.componentregistry.model.RegistryUser;
     
    2931    @SpringBean
    3032    private UserDao userDao;
     33    @SpringBean(name = "componentRegistryFactory")
     34    private ComponentRegistryFactory componentRegistryFactory;
    3135    private RegistryUser registryUser;
    3236
     
    3539
    3640        Principal userPrincipal = ((WebRequestCycle) (RequestCycle.get())).getWebRequest().getHttpServletRequest().getUserPrincipal();
    37         registryUser = userDao.getByPrincipalName(userPrincipal.getName());
    38        
     41        registryUser = componentRegistryFactory.getOrCreateUser(new UserCredentials(userPrincipal));
     42
    3943        add(new Label("userName", registryUser.getPrincipalName()));
    4044
  • ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryFactoryDbImpl.java

    r1698 r1864  
    2020 * ComponentRegistryDbImpl implementation of ComponentRegistry for accessing the
    2121 * registry
    22  * 
     22 *
    2323 * @author Twan Goosen <twan.goosen@mpi.nl>
    2424 */
     
    118118        RegistryUser user = userDao.getByPrincipalName(principalName);
    119119        if (user == null) {
     120            LOG.info("Request to create user with principal name {} and display name {}", new Object[]{principalName, displayName});
    120121            // Create the new user
    121122            user = new RegistryUser();
  • ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r1753 r1864  
    8181
    8282    /**
    83      * 
     83     *
    8484     * @return Principal of current request
    8585     * @throws IllegalArgumentException If no user principal found
     
    281281
    282282    /**
    283      * 
     283     *
    284284     * Purely helper method for my front-end (FLEX) which only does post/get requests. The query param is checked and the "proper" method is
    285285     * called.
     286     *
    286287     * @param profileId
    287288     * @param method
     
    373374
    374375    /**
    375      * 
     376     *
    376377     * Purely helper method for my front-end (FLEX) which van only do post/get requests. The query param is checked and the "proper" method
    377378     * is called.
     379     *
    378380     * @param componentId
    379381     * @param method
  • 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.