Changeset 1864
- Timestamp:
- 04/05/12 15:38:51 (12 years ago)
- Location:
- ComponentRegistry/tags/ComponentRegistry-1.11.1
- Files:
-
- 19 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/tags/ComponentRegistry-1.11.1
- Property svn:mergeinfo changed
/ComponentRegistry/trunk (added) merged: 1859-1863
- Property svn:mergeinfo changed
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/CMDValidate/pom.xml
r1843 r1864 10 10 <groupId>clarin.cmdi</groupId> 11 11 <artifactId>cmd-validate</artifactId> 12 <version>1. 0</version>12 <version>1.1</version> 13 13 <name>CMDValidate</name> 14 14 <build> … … 45 45 <artifactId>junit</artifactId> 46 46 <version>4.10</version> 47 <scope>test</scope>48 47 </dependency> 49 48 <dependency> … … 51 50 <artifactId>Saxon-HE</artifactId> 52 51 <version>9.4</version> 52 </dependency> 53 <dependency> 54 <groupId>xml-resolver</groupId> 55 <artifactId>xml-resolver</artifactId> 56 <version>1.2</version> 57 <scope>test</scope> 53 58 </dependency> 54 59 </dependencies> -
ComponentRegistry/tags/ComponentRegistry-1.11.1/CMDValidate/src/main/java/clarin/cmdi/schema/cmd/Validator.java
r1843 r1864 25 25 import net.sf.saxon.s9api.XsltTransformer; 26 26 import org.w3c.dom.Document; 27 import org.w3c.dom.ls.LSResourceResolver; 27 28 import org.xml.sax.SAXException; 28 29 … … 64 65 */ 65 66 private XdmNode validationReport = null; 67 private LSResourceResolver resourceResolver = null; 66 68 67 69 /** … … 134 136 if (cmdSchema == null) { 135 137 SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); 138 if (getResourceResolver() != null) { 139 factory.setResourceResolver(getResourceResolver()); 140 } 136 141 137 142 // Load the CMD XSD. … … 374 379 375 380 /** 381 * @return Resource resolver used for schemata 382 */ 383 protected LSResourceResolver getResourceResolver() { 384 return resourceResolver; 385 } 386 387 /** 388 * @param resourceResolver Resource resolver to use for schemata 389 */ 390 public void setResourceResolver(LSResourceResolver resourceResolver) { 391 this.resourceResolver = resourceResolver; 392 } 393 394 /** 376 395 * Public inner class to represent validation messages. 377 396 */ -
ComponentRegistry/tags/ComponentRegistry-1.11.1/CMDValidate/src/test/java/clarin/cmdi/schema/cmd/TestCMDValidate.java
r1745 r1864 9 9 import javax.xml.transform.Source; 10 10 import org.junit.*; 11 11 12 import static org.junit.Assert.*; 12 13 … … 22 23 public void setUp() { 23 24 cmdValidator = new Validator(getClass().getResource("/schema/general-component-schema.xsd")); 25 cmdValidator.setResourceResolver(new ResourceResolver()); 24 26 } 25 27 -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentBrowserGui
- Property svn:mergeinfo changed (with no actual effect on merging)
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/ComponentRegistry (added) merged: 1860-1863
- Property svn:mergeinfo changed
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/CHANGES
r1844 r1864 1 1 Bug Fixes and Features 2 3 Release ComponentRegistry-1.11.1 (17 april 2012): 4 - Fixed caching of w3c xml.xsd schema in validator 5 - Fixes issue with user settings page users without user entry in database 2 6 3 7 Release ComponentRegistry-1.11.0 (3 april 2012): -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/pom.xml
r1816 r1864 185 185 <groupId>clarin.cmdi</groupId> 186 186 <artifactId>cmd-validate</artifactId> 187 <version>1. 0</version>187 <version>1.1</version> 188 188 </dependency> 189 189 </dependencies> -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/binding
- Property svn:mergeinfo changed (with no actual effect on merging)
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/binding/bindings.xjb
- Property svn:mergeinfo changed (with no actual effect on merging)
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/ComponentRegistry/src/main/java (added) merged: 1860,1862-1863
- Property svn:mergeinfo changed
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/MDMarshaller.java
r1816 r1864 41 41 private final static Logger LOG = LoggerFactory.getLogger(MDMarshaller.class); 42 42 /** 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. 44 46 */ 45 47 private static final String W3C_XML_SCHEMA_NS_URI = "http://www.w3.org/2001/XMLSchema"; … … 65 67 66 68 /** 67 * 69 * 68 70 * @param docClass 69 71 * @param inputStream … … 102 104 } 103 105 104 public static Schema getCMDComponentSchema() {106 public static synchronized Schema getCMDComponentSchema() { 105 107 if (generalComponentSchema == null) { 106 108 try { 107 109 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()); 134 111 generalComponentSchema = schemaFactory.newSchema(new URL(Configuration.getInstance().getGeneralComponentSchema())); 135 112 } catch (MalformedURLException e) { … … 169 146 } 170 147 171 172 173 148 private static String getSpecId(CMDComponentSpec spec) { 174 149 String result = ""; -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/UserSettingsPage.java
r1779 r1864 5 5 package clarin.cmdi.componentregistry.frontend; 6 6 7 import clarin.cmdi.componentregistry.ComponentRegistryFactory; 8 import clarin.cmdi.componentregistry.UserCredentials; 7 9 import clarin.cmdi.componentregistry.impl.database.UserDao; 8 10 import clarin.cmdi.componentregistry.model.RegistryUser; … … 29 31 @SpringBean 30 32 private UserDao userDao; 33 @SpringBean(name = "componentRegistryFactory") 34 private ComponentRegistryFactory componentRegistryFactory; 31 35 private RegistryUser registryUser; 32 36 … … 35 39 36 40 Principal userPrincipal = ((WebRequestCycle) (RequestCycle.get())).getWebRequest().getHttpServletRequest().getUserPrincipal(); 37 registryUser = userDao.getByPrincipalName(userPrincipal.getName());38 41 registryUser = componentRegistryFactory.getOrCreateUser(new UserCredentials(userPrincipal)); 42 39 43 add(new Label("userName", registryUser.getPrincipalName())); 40 44 -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryFactoryDbImpl.java
r1698 r1864 20 20 * ComponentRegistryDbImpl implementation of ComponentRegistry for accessing the 21 21 * registry 22 * 22 * 23 23 * @author Twan Goosen <twan.goosen@mpi.nl> 24 24 */ … … 118 118 RegistryUser user = userDao.getByPrincipalName(principalName); 119 119 if (user == null) { 120 LOG.info("Request to create user with principal name {} and display name {}", new Object[]{principalName, displayName}); 120 121 // Create the new user 121 122 user = new RegistryUser(); -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r1753 r1864 81 81 82 82 /** 83 * 83 * 84 84 * @return Principal of current request 85 85 * @throws IllegalArgumentException If no user principal found … … 281 281 282 282 /** 283 * 283 * 284 284 * Purely helper method for my front-end (FLEX) which only does post/get requests. The query param is checked and the "proper" method is 285 285 * called. 286 * 286 287 * @param profileId 287 288 * @param method … … 373 374 374 375 /** 375 * 376 * 376 377 * Purely helper method for my front-end (FLEX) which van only do post/get requests. The query param is checked and the "proper" method 377 378 * is called. 379 * 378 380 * @param componentId 379 381 * @param method -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java
r1816 r1864 3 3 import clarin.cmdi.componentregistry.ComponentRegistry; 4 4 import clarin.cmdi.componentregistry.ComponentRegistryException; 5 import clarin.cmdi.componentregistry.ComponentRegistryResourceResolver; 5 6 import clarin.cmdi.componentregistry.Configuration; 6 7 import clarin.cmdi.componentregistry.MDMarshaller; … … 28 29 29 30 public class MDValidator implements Validator { 30 31 31 32 private final static Logger LOG = LoggerFactory.getLogger(MDValidator.class); 32 33 static final String MISMATCH_ERROR = "Cannot register component as a profile or vica versa."; … … 49 50 50 51 /** 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. 53 55 * @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 56 59 */ 57 60 public MDValidator(InputStream input, AbstractDescription description, ComponentRegistry registry, ComponentRegistry userRegistry, ComponentRegistry publicRegistry) { … … 62 65 this.publicRegistry = publicRegistry; 63 66 } 64 67 65 68 @Override 66 69 public List<String> getErrorMessages() { 67 70 return errorMessages; 68 71 } 69 72 70 73 @Override 71 74 public boolean validate() { 72 75 try { 73 76 clarin.cmdi.schema.cmd.Validator validator = new clarin.cmdi.schema.cmd.Validator(new URL(Configuration.getInstance().getGeneralComponentSchema())); 77 validator.setResourceResolver(new ComponentRegistryResourceResolver()); 74 78 // We may need to reuse the input stream, so save it to a byte array first 75 79 byte[] inputBytes = getBytesFromInputStream(); … … 109 113 return errorMessages.isEmpty(); 110 114 } 111 115 112 116 private byte[] getBytesFromInputStream() throws IOException { 113 117 int len; 114 118 byte[] b = new byte[4096]; 115 119 final ByteArrayOutputStream bOS = new ByteArrayOutputStream(); 116 120 117 121 while ((len = input.read(b)) > 0) { 118 122 bOS.write(b, 0, len); 119 123 } 120 124 121 125 return bOS.toByteArray(); 122 126 } 123 127 124 128 private void validateComponents(List<CMDComponentType> cmdComponents) throws ComponentRegistryException { 125 129 for (CMDComponentType cmdComponentType : cmdComponents) { … … 128 132 } 129 133 } 130 134 131 135 private void validateDescribedComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException { 132 136 checkPublicComponents(cmdComponentType); 133 137 } 134 138 135 139 private void checkPublicComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException { 136 140 if (isDefinedInSeparateFile(cmdComponentType)) { … … 157 161 } 158 162 } 159 163 160 164 } 161 165 } 162 166 } 163 167 164 168 private boolean isDefinedInSeparateFile(CMDComponentType cmdComponentType) { 165 169 return cmdComponentType.getName() == null; 166 170 } 167 171 168 172 public CMDComponentSpec getCMDComponentSpec() { 169 173 return spec; -
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/test/java
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/ComponentRegistry/src/test/java (added) merged: 1861
- Property svn:mergeinfo changed
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ConcurrentRestServiceTest.java
r1603 r1864 3 3 import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase; 4 4 import clarin.cmdi.componentregistry.model.AbstractDescription; 5 import static clarin.cmdi.componentregistry.rest.ComponentRegistryRestService.USERSPACE_PARAM; 6 import static org.junit.Assert.assertEquals; 7 import static org.junit.Assert.fail; 8 5 import clarin.cmdi.componentregistry.model.ComponentDescription; 6 import clarin.cmdi.componentregistry.model.ProfileDescription; 7 import clarin.cmdi.componentregistry.model.RegisterResponse; 8 import com.sun.jersey.api.client.ClientResponse; 9 import com.sun.jersey.multipart.FormDataMultiPart; 9 10 import java.io.InputStream; 10 11 import java.util.ArrayList; 11 12 import java.util.Arrays; 13 import java.util.Collections; 14 import java.util.Comparator; 12 15 import java.util.List; 13 14 16 import javax.ws.rs.core.MediaType; 15 16 17 import org.junit.Before; 17 18 import org.junit.Test; 18 19 import org.junit.runner.RunWith; 19 20 import clarin.cmdi.componentregistry.model.ComponentDescription;21 import clarin.cmdi.componentregistry.model.ProfileDescription;22 import clarin.cmdi.componentregistry.model.RegisterResponse;23 24 import com.sun.jersey.api.client.ClientResponse;25 import com.sun.jersey.multipart.FormDataMultiPart;26 import java.util.Collections;27 import java.util.Comparator;28 20 import org.slf4j.Logger; 29 21 import org.slf4j.LoggerFactory; … … 33 25 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 34 26 27 import static clarin.cmdi.componentregistry.rest.ComponentRegistryRestService.USERSPACE_PARAM; 28 import static org.junit.Assert.*; 29 35 30 @RunWith(SpringJUnit4ClassRunner.class) 36 @ContextConfiguration(locations = { "/applicationContext.xml"})31 @ContextConfiguration(locations = {"/applicationContext.xml"}) 37 32 public class ConcurrentRestServiceTest extends ComponentRegistryRestServiceTestCase { 38 33 39 34 private final static Logger LOG = LoggerFactory.getLogger(ConcurrentRestServiceTest.class); 40 private int NR_OF_PROFILES = 50; 41 private int NR_OF_COMPONENTS = 50; 42 35 private int NR_OF_PROFILES = 20; 36 private int NR_OF_COMPONENTS = 20; 43 37 @Autowired 44 38 private JdbcTemplate jdbcTemplate; … … 54 48 return "classpath:applicationContext.xml"; 55 49 } 56 50 57 51 @Test 58 52 public void testConcurrentRegisterProfile() throws Exception { … … 125 119 for (int i = 0; i < size; i++) { 126 120 final boolean shouldDelete = (i % 2) == 1; 121 LOG.debug("Profile {} should be registered in {} and {}", new Object[]{i + 1000, Boolean.parseBoolean(userSpace) ? "user space" : "public space", shouldDelete ? "ALSO DELETED" : "not deleted"}); 127 122 Thread thread = createThread("/registry/profiles/", userSpace, "Test Profile" + (i + 1000), shouldDelete, RegistryTestHelper.getTestProfileContent(), errors); 128 123 ts.add(thread); … … 133 128 for (int i = 0; i < size; i++) { 134 129 final boolean shouldDelete = (i % 2) == 1; 130 LOG.debug("Component {} should be registered in {} and {}", new Object[]{i + 1000, Boolean.parseBoolean(userSpace) ? "user space" : "public space", shouldDelete ? "ALSO DELETED" : "not deleted"}); 135 131 Thread thread = createThread("/registry/components/", userSpace, "Test Component" + (i + 1000), shouldDelete, 136 132 RegistryTestHelper.getComponentTestContent(), errors); -
ComponentRegistry/tags/ComponentRegistry-1.11.1/README
- Property svn:mergeinfo changed (with no actual effect on merging)
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/docs
- Property svn:mergeinfo changed (with no actual effect on merging)
-
ComponentRegistry/tags/ComponentRegistry-1.11.1/pom.xml
- Property svn:mergeinfo changed (with no actual effect on merging)
r1843 r1864 22 22 <properties> 23 23 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 24 <ComponentBrowserGui.version>1.11. 0</ComponentBrowserGui.version>25 <ComponentRegistry.version>1.11. 0</ComponentRegistry.version>24 <ComponentBrowserGui.version>1.11.1</ComponentBrowserGui.version> 25 <ComponentRegistry.version>1.11.1</ComponentRegistry.version> 26 26 </properties> 27 27
Note: See TracChangeset
for help on using the changeset viewer.