- Timestamp:
- 04/05/12 15:38:51 (12 years ago)
- Location:
- ComponentRegistry/tags/ComponentRegistry-1.11.1
- Files:
-
- 7 edited
- 2 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/ComponentRegistry
- Property svn:mergeinfo changed
/ComponentRegistry/trunk/ComponentRegistry (added) merged: 1860-1863
- Property svn:mergeinfo changed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.