Index: /ComponentRegistry/trunk/ComponentRegistry/pom.xml
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/pom.xml	(revision 1859)
+++ /ComponentRegistry/trunk/ComponentRegistry/pom.xml	(revision 1860)
@@ -185,5 +185,5 @@
 	    <groupId>clarin.cmdi</groupId>
 	    <artifactId>cmd-validate</artifactId>
-	    <version>1.0</version>
+	    <version>1.1</version>
 	</dependency>
     </dependencies>
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistryResourceResolver.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistryResourceResolver.java	(revision 1860)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistryResourceResolver.java	(revision 1860)
@@ -0,0 +1,44 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package clarin.cmdi.componentregistry;
+
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.InputSource;
+
+/**
+ *
+ * @author Twan Goosen <twan.goosen@mpi.nl>
+ */
+public class ComponentRegistryResourceResolver implements LSResourceResolver {
+
+    private CatalogResolver catRes = new CatalogResolver();
+
+    @Override
+    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
+	InputSource resolveEntity = catRes.resolveEntity(publicId, systemId);
+	resolveEntity.setEncoding("UTF-8");
+	DOMImplementationLS domImplementation;
+	try {
+	    domImplementation = (DOMImplementationLS) DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
+	} catch (ClassCastException e) {
+	    throw new RuntimeException(e);
+	} catch (ClassNotFoundException e) {
+	    throw new RuntimeException(e);
+	} catch (InstantiationException e) {
+	    throw new RuntimeException(e);
+	} catch (IllegalAccessException e) {
+	    throw new RuntimeException(e);
+	}
+	LSInput lsInput = domImplementation.createLSInput();
+	lsInput.setEncoding("UTF-8");
+	lsInput.setByteStream(resolveEntity.getByteStream());
+	lsInput.setCharacterStream(resolveEntity.getCharacterStream());
+	return lsInput;
+    }
+}
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/MDMarshaller.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/MDMarshaller.java	(revision 1859)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/MDMarshaller.java	(revision 1860)
@@ -41,5 +41,7 @@
     private final static Logger LOG = LoggerFactory.getLogger(MDMarshaller.class);
     /**
-     * I define W3C_XML_SCHEMA_NS_URI here cannot get it from @see XMLConstants there is a conflict between stax-api and java5.
+     * I define W3C_XML_SCHEMA_NS_URI here cannot get it from
+     *
+     * @see XMLConstants there is a conflict between stax-api and java5.
      */
     private static final String W3C_XML_SCHEMA_NS_URI = "http://www.w3.org/2001/XMLSchema";
@@ -65,5 +67,5 @@
 
     /**
-     * 
+     *
      * @param docClass
      * @param inputStream
@@ -102,34 +104,9 @@
     }
 
-    public static Schema getCMDComponentSchema() {
+    public static synchronized Schema getCMDComponentSchema() {
 	if (generalComponentSchema == null) {
 	    try {
 		SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
-		schemaFactory.setResourceResolver(new LSResourceResolver() {
-		    private CatalogResolver catRes = new CatalogResolver();
-
-		    @Override
-		    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
-			InputSource resolveEntity = catRes.resolveEntity(publicId, systemId);
-			resolveEntity.setEncoding("UTF-8");
-			DOMImplementationLS domImplementation;
-			try {
-			    domImplementation = (DOMImplementationLS) DOMImplementationRegistry.newInstance().getDOMImplementation("LS");
-			} catch (ClassCastException e) {
-			    throw new RuntimeException(e);
-			} catch (ClassNotFoundException e) {
-			    throw new RuntimeException(e);
-			} catch (InstantiationException e) {
-			    throw new RuntimeException(e);
-			} catch (IllegalAccessException e) {
-			    throw new RuntimeException(e);
-			}
-			LSInput lsInput = domImplementation.createLSInput();
-			lsInput.setEncoding("UTF-8");
-			lsInput.setByteStream(resolveEntity.getByteStream());
-			lsInput.setCharacterStream(resolveEntity.getCharacterStream());
-			return lsInput;
-		    }
-		});
+		schemaFactory.setResourceResolver(new ComponentRegistryResourceResolver());
 		generalComponentSchema = schemaFactory.newSchema(new URL(Configuration.getInstance().getGeneralComponentSchema()));
 	    } catch (MalformedURLException e) {
@@ -169,6 +146,4 @@
     }
 
-    
-    
     private static String getSpecId(CMDComponentSpec spec) {
 	String result = "";
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 1859)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 1860)
@@ -52,5 +52,5 @@
 @Path("/registry")
 public class ComponentRegistryRestService {
-
+    
     @Context
     private UriInfo uriInfo;
@@ -69,5 +69,5 @@
     @Inject(value = "componentRegistryFactory")
     private ComponentRegistryFactory componentRegistryFactory;
-
+    
     private ComponentRegistry getRegistry(boolean userspace) {
 	Principal userPrincipal = security.getUserPrincipal();
@@ -75,5 +75,5 @@
 	return getRegistry(userspace, userCredentials);
     }
-
+    
     private ComponentRegistry getRegistry(boolean userspace, UserCredentials userCredentials) {
 	return componentRegistryFactory.getComponentRegistry(userspace, userCredentials);
@@ -81,5 +81,5 @@
 
     /**
-     * 
+     *
      * @return Principal of current request
      * @throws IllegalArgumentException If no user principal found
@@ -92,5 +92,5 @@
 	return principal;
     }
-
+    
     private UserCredentials getUserCredentials(Principal userPrincipal) {
 	UserCredentials userCredentials = null;
@@ -100,5 +100,5 @@
 	return userCredentials;
     }
-
+    
     @GET
     @Path("/components")
@@ -111,5 +111,5 @@
 	return components;
     }
-
+    
     @GET
     @Path("/profiles")
@@ -118,5 +118,5 @@
 	    @QueryParam(METADATA_EDITOR_PARAM) @DefaultValue("false") boolean metadataEditor) throws ComponentRegistryException {
 	long start = System.currentTimeMillis();
-
+	
 	List<ProfileDescription> profiles;
 	if (metadataEditor) {
@@ -125,10 +125,10 @@
 	    profiles = getRegistry(userspace).getProfileDescriptions();
 	}
-
+	
 	LOG.info("Releasing " + profiles.size() + " registered profiles into the world (" + (System.currentTimeMillis() - start)
 		+ " millisecs)");
 	return profiles;
     }
-
+    
     @GET
     @Path("/components/{componentId}")
@@ -139,5 +139,5 @@
 	return getRegistry(userspace).getMDComponent(componentId);
     }
-
+    
     @GET
     @Path("/components/{componentId}/{rawType}")
@@ -156,5 +156,5 @@
 	    if ("xml".equalsIgnoreCase(rawType)) {
 		result = new StreamingOutput() {
-
+		    
 		    @Override
 		    public void write(OutputStream output) throws IOException, WebApplicationException {
@@ -169,5 +169,5 @@
 	    } else if ("xsd".equalsIgnoreCase(rawType)) {
 		result = new StreamingOutput() {
-
+		    
 		    @Override
 		    public void write(OutputStream output) throws IOException, WebApplicationException {
@@ -178,5 +178,5 @@
 			    throw new WebApplicationException(e, Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build());
 			}
-
+			
 		    }
 		};
@@ -191,5 +191,5 @@
 	}
     }
-
+    
     public ComponentRegistry findRegistry(String id, RegistryClosure<? extends AbstractDescription> clos) throws ComponentRegistryException {
 	AbstractDescription desc = null;
@@ -208,5 +208,5 @@
 	return result;
     }
-
+    
     @GET
     @Path("/profiles/{profileId}")
@@ -217,5 +217,5 @@
 	return getRegistry(userspace).getMDProfile(profileId);
     }
-
+    
     @GET
     @Path("/components/usage/{componentId}")
@@ -227,12 +227,12 @@
 	    List<ComponentDescription> components = registry.getUsageInComponents(componentId);
 	    List<ProfileDescription> profiles = registry.getUsageInProfiles(componentId);
-
+	    
 	    LOG.info("Found " + components.size() + " components and " + profiles.size() + " profiles that use component " + componentId
 		    + " (" + (System.currentTimeMillis() - start) + " millisecs)");
-
+	    
 	    List<AbstractDescription> usages = new ArrayList<AbstractDescription>(components.size() + profiles.size());
 	    usages.addAll(components);
 	    usages.addAll(profiles);
-
+	    
 	    return usages;
 	} catch (ComponentRegistryException e) {
@@ -241,5 +241,5 @@
 	}
     }
-
+    
     @GET
     @Path("/profiles/{profileId}/comments")
@@ -252,5 +252,5 @@
 	return comments;
     }
-
+    
     @GET
     @Path("/components/{componentId}/comments")
@@ -263,5 +263,5 @@
 	return comments;
     }
-
+    
     @GET
     @Path("/profiles/{profileId}/comments/{commentId}")
@@ -271,5 +271,5 @@
 	return getRegistry(userspace).getSpecifiedCommentInProfile(profileId, commentId);
     }
-
+    
     @GET
     @Path("/components/{componentId}/comments/{commentId}")
@@ -281,7 +281,8 @@
 
     /**
-     * 
+     *
      * Purely helper method for my front-end (FLEX) which only does post/get requests. The query param is checked and the "proper" method is
      * called.
+     *
      * @param profileId
      * @param method
@@ -298,5 +299,5 @@
 	}
     }
-
+    
     @POST
     @Path("/profiles/{profileId}/comments/{commentId}")
@@ -309,5 +310,5 @@
 	}
     }
-
+    
     @POST
     @Path("/components/{componentId}/comments/{commentId}")
@@ -320,5 +321,5 @@
 	}
     }
-
+    
     @POST
     @Path("/profiles/{profileId}/publish")
@@ -344,5 +345,5 @@
 	}
     }
-
+    
     @POST
     @Path("/profiles/{profileId}/update")
@@ -369,11 +370,12 @@
 	    return Response.status(Status.UNAUTHORIZED).entity(ex.getMessage()).build();
 	}
-
+	
     }
 
     /**
-     * 
+     *
      * Purely helper method for my front-end (FLEX) which van only do post/get requests. The query param is checked and the "proper" method
      * is called.
+     *
      * @param componentId
      * @param method
@@ -390,5 +392,5 @@
 	}
     }
-
+    
     @POST
     @Path("/components/{componentId}/publish")
@@ -415,5 +417,5 @@
 	}
     }
-
+    
     @POST
     @Path("/components/{componentId}/update")
@@ -440,5 +442,5 @@
 	}
     }
-
+    
     private void updateDescription(AbstractDescription desc, String name, String description, String domainName, String group) {
 	desc.setName(name);
@@ -448,5 +450,5 @@
 	desc.setRegistrationDate(AbstractDescription.createNewDate());
     }
-
+    
     @DELETE
     @Path("/components/{componentId}")
@@ -474,5 +476,5 @@
 	return Response.ok().build();
     }
-
+    
     @DELETE
     @Path("/profiles/{profileId}")
@@ -499,5 +501,5 @@
 	return Response.ok().build();
     }
-
+    
     @DELETE
     @Path("/profiles/{profileId}/comments/{commentId}")
@@ -530,5 +532,5 @@
 	return Response.ok().build();
     }
-
+    
     @DELETE
     @Path("/components/{componentId}/comments/{commentId}")
@@ -561,5 +563,5 @@
 	return Response.ok().build();
     }
-
+    
     @GET
     @Path("/profiles/{profileId}/{rawType}")
@@ -576,8 +578,8 @@
 	    checkAndThrowDescription(desc, profileId);
 	    String fileName = desc.getName() + "." + rawType;
-
+	    
 	    if ("xml".equalsIgnoreCase(rawType)) {
 		result = new StreamingOutput() {
-
+		    
 		    @Override
 		    public void write(OutputStream output) throws IOException, WebApplicationException {
@@ -592,5 +594,5 @@
 	    } else if ("xsd".equalsIgnoreCase(rawType)) {
 		result = new StreamingOutput() {
-
+		    
 		    @Override
 		    public void write(OutputStream output) throws IOException, WebApplicationException {
@@ -613,5 +615,5 @@
 	}
     }
-
+    
     private void checkAndThrowDescription(AbstractDescription desc, String id) {
 	if (desc == null) {
@@ -619,5 +621,5 @@
 	}
     }
-
+    
     private Response createDownloadResponse(StreamingOutput result, String fileName) {
 	//Making response so it triggers browsers native save as dialog.
@@ -625,7 +627,7 @@
 		"attachment; filename=\"" + fileName + "\"").entity(result).build();
 	return response;
-
-    }
-
+	
+    }
+    
     @POST
     @Path("/profiles")
@@ -651,5 +653,5 @@
 	}
     }
-
+    
     @POST
     @Path("/components")
@@ -675,5 +677,5 @@
 	}
     }
-
+    
     @POST
     @Path("/components/{componentId}/comments")
@@ -701,5 +703,5 @@
 	}
     }
-
+    
     @POST
     @Path("/profiles/{profileId}/comments")
@@ -727,5 +729,5 @@
 	}
     }
-
+    
     @GET
     @Path("/pingSession")
@@ -742,5 +744,5 @@
 	return Response.ok().entity("<session stillActive=\"" + stillActive + "\"/>").build();
     }
-
+    
     private Response register(InputStream input, AbstractDescription desc, UserCredentials userCredentials, boolean userspace,
 	    RegisterAction action) {
@@ -777,4 +779,5 @@
 	    }
 	    response.setIsProfile(desc.isProfile());
+	    LOG.info("Registration of {} successful: {}", response.getDescription().getId(), response.isRegistered());
 	    return Response.ok(response).build();
 	} finally {
@@ -786,5 +789,5 @@
 	}
     }
-
+    
     private Response registerComment(InputStream input, ComponentRegistry registry, boolean userspace,
 	    AbstractDescription description, Principal principal, UserCredentials userCredentials) {
@@ -806,5 +809,5 @@
 		    }
 		}
-
+		
 		int returnCode = registry.registerComment(com, principal.getName());
 		if (returnCode == 0) {
@@ -832,5 +835,5 @@
 	}
     }
-
+    
     private ComponentDescription createNewComponentDescription() {
 	ComponentDescription desc = ComponentDescription.createNewDescription();
@@ -838,5 +841,5 @@
 	return desc;
     }
-
+    
     private ProfileDescription createNewProfileDescription() {
 	ProfileDescription desc = ProfileDescription.createNewDescription();
@@ -844,15 +847,15 @@
 	return desc;
     }
-
+    
     private Comment createNewComment() {
 	Comment com = Comment.createANewComment();
 	return com;
     }
-
+    
     private String createXlink(String id) {
 	URI uri = uriInfo.getRequestUriBuilder().path(id).build();
 	return uri.toString();
     }
-
+    
     private void validate(RegisterResponse response, Validator... validators) {
 	for (Validator validator : validators) {
@@ -864,5 +867,5 @@
 	}
     }
-
+    
     private void validateComment(CommentResponse response, Validator... validators) {
 	for (Validator validator : validators) {
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java	(revision 1859)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java	(revision 1860)
@@ -3,4 +3,5 @@
 import clarin.cmdi.componentregistry.ComponentRegistry;
 import clarin.cmdi.componentregistry.ComponentRegistryException;
+import clarin.cmdi.componentregistry.ComponentRegistryResourceResolver;
 import clarin.cmdi.componentregistry.Configuration;
 import clarin.cmdi.componentregistry.MDMarshaller;
@@ -28,5 +29,5 @@
 
 public class MDValidator implements Validator {
-
+    
     private final static Logger LOG = LoggerFactory.getLogger(MDValidator.class);
     static final String MISMATCH_ERROR = "Cannot register component as a profile or vica versa.";
@@ -49,9 +50,11 @@
 
     /**
-     * 
-     * @param input In order to validate the input is consumed. So use @see getCMDComponentSpec to get the parsed CMDComponentSpec.
+     *
+     * @param input In order to validate the input is consumed. So use
+     * @see getCMDComponentSpec to get the parsed CMDComponentSpec.
      * @param desc
-     * @param registry (registry you currently used) 
-     * @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
+     * @param registry (registry you currently used)
+     * @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
      */
     public MDValidator(InputStream input, AbstractDescription description, ComponentRegistry registry, ComponentRegistry userRegistry, ComponentRegistry publicRegistry) {
@@ -62,14 +65,15 @@
 	this.publicRegistry = publicRegistry;
     }
-
+    
     @Override
     public List<String> getErrorMessages() {
 	return errorMessages;
     }
-
+    
     @Override
     public boolean validate() {
 	try {
 	    clarin.cmdi.schema.cmd.Validator validator = new clarin.cmdi.schema.cmd.Validator(new URL(Configuration.getInstance().getGeneralComponentSchema()));
+	    validator.setResourceResolver(new ComponentRegistryResourceResolver());
 	    // We may need to reuse the input stream, so save it to a byte array first
 	    byte[] inputBytes = getBytesFromInputStream();
@@ -109,17 +113,17 @@
 	return errorMessages.isEmpty();
     }
-
+    
     private byte[] getBytesFromInputStream() throws IOException {
 	int len;
 	byte[] b = new byte[4096];
 	final ByteArrayOutputStream bOS = new ByteArrayOutputStream();
-
+	
 	while ((len = input.read(b)) > 0) {
 	    bOS.write(b, 0, len);
 	}
-
+	
 	return bOS.toByteArray();
     }
-
+    
     private void validateComponents(List<CMDComponentType> cmdComponents) throws ComponentRegistryException {
 	for (CMDComponentType cmdComponentType : cmdComponents) {
@@ -128,9 +132,9 @@
 	}
     }
-
+    
     private void validateDescribedComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException {
 	checkPublicComponents(cmdComponentType);
     }
-
+    
     private void checkPublicComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException {
 	if (isDefinedInSeparateFile(cmdComponentType)) {
@@ -157,13 +161,13 @@
 		    }
 		}
-
+		
 	    }
 	}
     }
-
+    
     private boolean isDefinedInSeparateFile(CMDComponentType cmdComponentType) {
 	return cmdComponentType.getName() == null;
     }
-
+    
     public CMDComponentSpec getCMDComponentSpec() {
 	return spec;
